Here is a function from the Exercise 2: Includes of the Arrays sub-course in Mosh’s javascript course 1. I need to know why when the if statement is true and we jump out of the loop. The next line doesn’t get executed but if the if statement is false, the next line is executed
Code:
function includes(array, searchElement) {
for (let element of array)
if (element === searchElement) return true;
*// Why does this next line not get executed if the 'if' statement above is true?*
return false;
}