Skip to content

Instantly share code, notes, and snippets.

@kevgathuku
Created October 12, 2014 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevgathuku/23b7553d2fe82460b295 to your computer and use it in GitHub Desktop.
Save kevgathuku/23b7553d2fe82460b295 to your computer and use it in GitHub Desktop.
Breaking out of a continuous loop in JS
var contain=new Array;
for (var current = 2; ; current++) {
if (current % 7 == 0)
contain[contain.length] = current;
//Common gotcha. use two equals signs for comparison
if (contain.length == 5)
break;
}
console.log(contain);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment