mercredi 23 juin 2021

I am trying to test elements in two arrays, and the first element in the second array is not getting tested

function six(sll) {
  let list = [];
  for (i = 0; i < sll.length; i++) {
    console.log(sll[i]);
    //these are my if statements to test elements
    if (sll[i].slice(0, 1) !== "e" && sll[i].length < 6) {
      list.push(sll[i]);
    } else if (sll[i].length > 6 && sll[i].slice(0, 1) === "e") {
      list.push(sll[i]);
    }
  }
  return list;
}
//this is my first array
let sxt = ["taco", "eggs", "excellent", "exponent", "artistic", "cat", "eat"];
console.log(six(sxt));
//this is my second array and the word eating is not being tested
let xxx = ["eating", "proper", "key", "earth"];
console.log(six(xxx));

Aucun commentaire:

Enregistrer un commentaire