I need to get the elements from an array that do not have the letter 'l'
in them and push it to another array, just using the for
loop. For this project no special methods are allowed. I can only use the push()
and toLowerCase()
methods.
The result I get is a list of all the names repeated multiple times.
var list =['sage', 'carolina', 'everly', 'carlos', 'frankie'];
var list1 =[];
for(let i in list){
for(let j in list[i]){
//Get name without the 'l'
if(list[i][j].toLowerCase() !== 'l'){
list1.push(list[i]);
}
}
}
console.log(list1);
2
Answers
A few notes to make:
Shorter version below: