mardi 10 juillet 2018

java for if array comparison statement

I am trying to compare array1 to array2 items. If array(position 1) > array(position1) return as A (+1) If array(position 1) < array(position1) return as B (+1) This will keep looping until it finishes and returns console.log (A + B). i am new to javascript please help

const X= [5,8,7,8];
const Y= [3,6,10,10];
for (var i=0; i < X.length;i++){
   if(x[i] > y[i]) {
      return A++;
   }
   else if (x[i] < y[i]) {
   let B=0
  return B++;
   }
    console.log([A] +[b]);
}

Aucun commentaire:

Enregistrer un commentaire