How to exit of a nested loop.
var indexOuterLoop, iterationsOuterLoop = 1000, indexInnerLoop, iterationsInnerLoop = 100; outer: for (indexOuterLoop = 0; indexOuterLoop < 1000; indexOuterLoop++) { inner: for (indexInnerLoop = 0; indexInnerLoop < iterationsInnerLoop; indexInnerLoop++) { if (indexInnerLoop === 10) { console.log( 'indexInnerLoop is equals to 10' ); break outer; } } } console.log( indexOuterLoop ); // Should log 0.
assert(items[0] === 'indexInnerLoop is equals to 10' && items[1] === 0);
var items = []; var backConsole = console; var counter var console = { log: function (str) { items.push(str); counter++; if(counter === 2){ console = backConsole; } } };