Why does the while loop print 4 twice?


#1


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


why does it print 4 twice?


var num = 2

while(num < 5) {
    console.log(num)
    num++
}


#2

The extra 4 is what is returned after the program is done. It is not related to the console.log(num).


#3

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