It is said that “RETURN” statement terminates a for loop in javascript but in this case the code will still output 3 why? does that mean the return statement doesn’t terminate the loop?
var printNumTwo;
for (var i = 0; i < 3; i++) {
if (i === 2) {
printNumTwo = function() {
return i;
};
}
}
console.log(printNumTwo());