Lesson 5 Controlling the for loop


#1

Syntax error!

What am I doing wrong?

Instructions:
1:This code counts every number from 0 to 35.
2:Make it start counting from 5.
3:Stop the counting when it prints out 50.
4:Only count every fifth number. So we want to increment i by 5.

Urg... I find these instructions confusing!

My code:

for (var i = 0; i <= 50; i < 35; i+5;) {
console.log(i);
}


#2

FINALLY... Solved it... Knew it wasn't that hard

for (var i = 5; i < 51; i+=5) {
console.log(i);
}


#3

My god.. why didn't I think of that. Thanks.


#4

for (var i=0; i<=50; i+=5;){

console.log(i);
}

This should do the trick


#5

pinched myself when i saw this lol thanks


#6

I just did that and I only got an error
Which says: unexpected token.
But just where?!


#7

And it works..thanks:sweat_smile: