I couldn’t figure out why the following codes can’t convert newArr to lowercase. Does anyone have a clue?
It’s from the challenge on https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations
function mutation(arr) {
let newArr = arr.slice();
for(let i = 0; i < newArr.length; i++){
newArr[i].toLowerCase();
console.log(newArr[i].toLowerCase()) // log hello hello
console.log(newArr) // still log [ 'hello', 'Hello' ]
}
}
mutation(["hello", "Hello"]);
Thanks for reading!