Repl.it Precourse assignment help!

I am confused. It says to write my own loop and a variable is named for me which is "count" and it tells me to add 1 to loop till it gets to 10. I think my loop is correct since i didnt stray too far from the first loop in the repl.it assignment.... please help!

function exerciseOne(){
// In this exercise, write a simple 'for loop' that starts the variable 'i' at 0 and
// increases i until it reaches 6.
// Fill in the blanks in the parentheses, and then console.log(i) inside of the fo loop
for( let i = 0; i < 6; i++){
console.log("This is i:", i)
}

}

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++){
console.log(count)
}
return count;
}

You are viewing a single comment. View All
mwilki7 (280)
``````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++)
{
console.log(count)
}
return count;
}``````

JavaScript allows you to use multiple variables with the same name (not sure about the same scope, someone else will have to confirm that).

You have one 'count' in the first line
`let count = 0`
and another in the for loop
`for (let count = 0...)`
The for loop changes the new count instead of the old one.
We need to tell JavaScript not to make a new variable so change:

``    for (let count = 0...)``

to

``    for (count = 0...)``

Not adding the '...' dots of course.