I want to create a loop that will continue until it reaches an error then continues on...
for (var m = 0; m != 'Error'; m++)
If I push the iterations too high, it will throw a "TypeError", which indicates that the limit has been reached. This for loop exists inside another loop which needs to continue and not crash the script, just discontinue the loop.
Thanks!
EDIT CODE FOLLOWS:
for (var i = 0; i < 100; i++) {
var xml = fs.readFileSync('./Filename-' + (i + 100) + '.xml', 'utf-8');
var level1 = bb(xml)
for (var m = 0;; m++) {
try {
if (level1.data.level2[m].product.code == '7472558') {
console.log(level1.data.level2[m].product.code);
total++}
}
catch (e) {
break;
}
}
console.log(total)
}