Is there a Javascript equivalent of the python \'for-else\' loop, so something like this:
searched = input(\"Input: \"); for i in range(5): if i==searched:
Working example (you need to use the flag):
var search = function(num){ var found = false; for(var i=0; i<5; i++){ if(i===num){ console.log("Match found: "+ i); found = true; break; } } if(!found){ console.log("No match found!"); } };