4. Ending The For Loop


#1


https://www.codecademy.com/courses/javascript-beginner-en-NhsaT/0/4?curriculum_id=506324b3a7dffd00020bf661

Instructions:

We know this for loop counts from 1 to 10.
Change this for loop such that it starts at 4.
Change this for loop such that it counts up to and including 23. ( i.e. we do NOT want 24 to be printed out!)
Run your for loop and see it count from 4 to 23!


for (var i = 105; i <= 1; i  = i - 5) {
console.log(i);
};

It keeps saying, "Oops, try again. Your loop should have logged 4 to the console, but didn't!"

Someone help!!!


#2

This is not what the instructions ask for. How would we write this statement so that the output looks like this:

4
8
12
16
20

?


#3

I don't know. Thats why I asked. Please help!!!


#4

You have an example to work from.

for (var i = 1; i < 11; i += 1) {
    console.log(i);
}

Now what needs to change to output the above number list?


#7

please give me the code. I need to finish this by today!


#8

Don't fret. Finished it!:relieved:


#9

Good luck. Happy coding!


#10

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.