How do I use the js for loop condition to set up and exit?

var manySelectNote = [1,2,3,4,5,6]
for (i in manySelectNote){
  if (manySelectNote[i]>4) {
      console.log(1)
      break; 
  } else {
      console.log(2)
  }
}

Why do I use break , return , and sometimes execute console.log (2) ?

Mar.11,2021

is four 2s followed by a 1s and then exit the loop


according to you, loops should not be used here, but can be implemented in every

.
var manySelectNote = [1,2,3,4,5,6];
if(manySelectNote.every(value=>value<=4)){
    console.log(2);
}else{
    console.log(1);
}

will print four 2


this is not sometimes, is it four 2s and then one one?


http://www.runoob.com/js/js-s.

Menu