While Loop Continue Js Code Example

Snippet 1

  for (i = 0; i < 5; i++) {} 

Snippet 2

  for(var i=0;i<10;i++){
if(i==5){continue;}
console.log(i);
}

/*
returns 0 1 2 3 4 6 7 8 9
*/

for(var i=0;i<10;i++){
if(i==5){break;}
console.log(i);
}

/*
returns 0 1 2 3 4
*/ 

Copyright © Code Fetcher 2020

 

 

Published

Leave a comment

Your email address will not be published. Required fields are marked *