While Loop Basic Q



This is probably a simple question but any help is great! :blush: Under console.log what exactly does the variable = false do? I know you need it so you don't get trapped in an infinite loop but what does it do? if that makes any sense at all.

var i = true;

var soloLoop = function(){
  while (i === true) {  
    console.log("Looped once!");
    i = false;



it updates the variable i and gives it a value of false, so then when in the next run of the loop the condition is checked, it evaluates to false, the loop ends


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