Converting array to lowercase using for loop

Tell us what’s happening:

can someone help me identify why my for loop is only pushing one of the values from the array? I’m trying to create a new array with only lowercase values. Thank you!

Your code so far


function mutation(arr) {
// var lowercase = String(arr).toLowerCase();

for (let i = 0; i < arr.length; i++) {
var lowercase = []
lowercase.push(arr[i].toLowerCase());
}
console.log(lowercase)

let result = lowercase[0].indexOf(lowercase[1])

if (result > 0) {
return true
} else {
return false
}

return arr;
}

mutation(["hello", "hey"]);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36.

Challenge: Mutations

Link to the challenge:

lowercase starts at [] at each iteration, so it has never more than one element, maybe not the right place for initializing it

1 Like