Why does it output "0 besides the log above even I didn't console.log "i=0"?


in the console, why does it output 0? I am just make it false.

// Write your loop below!
var i=1;
while(i) {
    console.log("why does it output i=0?");


Our submitted code is entered at the command line of the JavaScript console. Unless that last executed 'command' is console.log() the response is the last assigned or computed value. In this case, i is assigned 0, so that is what echoes.

Try switching the two lines around and see what displays..


Thanks! When I switch the two lines, it is like miracle to me!:slight_smile:


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