How can I run the else part only after the end of the loop here? So right now: 10 is compared with 10, 20, 30. Then 40 is compared with 10, 20, 30. I want to get 40 only after it's been compared with all the values (10, 20, 30). I will want to do some calculations when 40 is missing from array 2. Right now it would be 40 == 10, it;s missing, do calculations, but I need it to compare all values then do the calculation.
alert("start")
var array1 = [10, 40];
var array2 = [10, 20, 30];
for (var x = 0; x < array2.length; x++) {
for (var y = 0; y < array1.length; y++) {
if (array1[y] != array2[x]) {
alert("Not Found")
} else {
alert("Found")
}
}
}