Tell us what’s happening:
Hi ya’ll! I got the correct answer to propagate, but I’d really like to understand the logical relationship in " ourArr[i] " What I mean is, where is that syntax explained? I get what the code is doing, but I don’t understand why it is written that way. Where can I read about square brackets being used this way?
Thank you!
Your code so far
// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;
for (var i = 0; i < ourArr.length; i++) {
ourTotal += ourArr[i];
}
var myArr = [ 2, 3, 4, 5, 6];
var total =0;
for (var i = 0; i < myArr.length; i++){
total += myArr[i];
}
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36 OPR/49.0.2725.64
.
Link to the challenge:
https://www.freecodecamp.org/challenges/iterate-through-an-array-with-a-for-loop