JS Assignment 5: For Loops
JerehlDyer (2)

What am I doing wrong here?

function exerciseTwo(){
let count = 0;
// In this exercise write your own for loop (you can look at the syntax above).
// It should loop 10 times.
// You are given a variable called: count .
// For each loop reassign count to the current value of count + 1 .
for( let count = 0; count <= 10; count++)
//Please write your answer in the line above.
return count;
}

You are viewing a single comment. View All
Answered by heyitsmarcus (284) [earned 5 cycles]
View Answer
mwilki7 (204)

It looks like you're using two definitions of "count"
let count = 0; on the 2nd line
and
for( let count = 0;..) on the 7th line

using the word 'let' in a different pair of brackets (for loop brackets in this case) will give you a brand new "count" and the old count doesnt get changed

So try removing the word "let" in the for loop and see if that does anything different.