Why does my While loop come out out with both "wow" and false?


#1

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


here is my code

for ( var i = 0; i<26; i+=4){
    console.log("im craaazyyy" + i++)
    }
    
    var i = true;
    while(i){console.log("wow");
    i=false;
    }
  
why does it log both wow and else?
it logs this

im craaazyyy0
im craaazyyy5
im craaazyyy10
im craaazyyy15
im craaazyyy20
im craaazyyy25
wow
false


#2

This is the last executed command, so the value of i is still in the buffer and handed back in the closing response. It can be ignored.


#3

I thought I needed to include that to avoid an infinite loop?


#4

Yes, leave the code where it is. It is needed. Just ignore the output.


#5

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