i have two arrays
newArray1 = [104,101,108,108,111];
and
newArray2 = [104,101,121];
im simply checking to see if certain numbers in array1 are in array2.
for(i=0;i<newArray2.length;i++) {
if(newArray.indexOf(newArray2[i]) > -1) {
console.log(newArray2[i]);
} else {
}
}
when looping through newArray2 the loop only iterates through position 0 and 1 , and does not get to the last number. Im just curious as to why the entire array is not being looped through entirely. When logging to the console in the body of the for loop
console.log(newArray2[i]);
I recieve
//104
//101
Not...
//104
//101
//121