Guys I just want to know when i run the code. In the end it displays 2. WHY!


#1


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


it works but displays 2 in the end.

0
1
2
2017 is going to be amazing!
2017 is going to be amazing!
2017 is going to be amazing!
2


for (var i=0; i<3; i++ ){
    console.log(i);
    }
    var x= false;
    while(x<3){
        console.log("2017 is going to be amazing!");
        x++;
        }


#2

its console behavior, you can overcome it by swapping x++ and the console.log statement around


#3

ohh alright thankss! :smiley:


#4

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