Loops - potatoscript/javascript GitHub Wiki

Loops

Do-While

  • The statement creates a loop that executes a block of code once, before checking if the condition is true, then it will repeat the loop as long as the condition is true.
   var i=0;
   do{
       document.write(i+" ");
       i++;
   }while(i<10);

for-in

  • loops through the properties of an object home
   var color = {color1:"yellow", color2:"blue", color3:"orange"};
   var output = "";
   for(var i in color){
    output += color[i] + " ";   => yellow blue orange
   }