When to 'while' and when to 'for'


#1


This not how my Saturday is suppose to start.

https://www.codecademy.com/en/courses/javascript-beginner-en-ASGIv/2/1?curriculum_id=506324b3a7dffd00020bf661

It passes but it does not execute my first line of code but not my second paragraph of code


var condition = true;

while(condition) {
    console.log("Looped once")
    // Do while condition is true
    condition = false;
}

var i = 1;

for (var i = 1; i < 11; i++) {
    // Print the numbers 1 - 10
    console.log(i);
}


#2

both the while and for loop are executed:

everything is good, what is the problem?


#3

it just runs the second part of the code,the "for" loop only.


#4

well, i see Looped once in the console (running your code), so the while loops runs as well. Both run. Maybe scroll in your console window? It is there


#5

nothing.. just the numbers. Its fine though, it passed me through without running it.
Thanks!


#6

okay, lets run it outside of codecademy, for example here (that is your code), i see looped once


#7

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