Thank you so much for your amazing explanation! I was struggling to understand the logic and what the code was even doing and now I’ve got such a clear understanding thanks to you! Really appreciate the time and effort you took to write it down!
This REALLY helped!!
I managed to solve the problem but I do not have a full understanding of how I did it. How does the loop come up with a number of 20?
I truly appreciate the detailed explanation.
This is so helpful. I found myself easily completing the task as the example spells it out a little too well but afterward I thought to myself I don’t understand why this worked. The explanation you gave really helped me understand the why. Thank you for taking the time to write all that out!
**
SPOILER ALERT:
**
This is how I did it:
// Setup
var myArr = [ 2, 3, 4, 5, 6];
// Only change code below this line
var total = 0;
for (var i = 0; i < myArr.length; i++) {
total += myArr[i];
}
Thanks everyone for the explanations. I initially declared my total variable inside the for loop so it kept resetting back to zero with each iteration. haha
Thanks for long explanation. Really helps me a lot. TQ
Hello I have a problem that I need help with. Maybe I am just not seeing something but I can’t find whats wrong with this. Can someone help me understand what I am doing wrong?
// Setup
var myArr = [ 2, 3, 4, 5, 6];
var total = 0;
// Only change code below this line
for (var i = 0; i < myArr.lenght; i++) {
total += myArr[i];
}
You changed code where you weren’t supposed to.
and you have a typo as well