function mutation(arr) {
var total = arr.map(function(x){return x.toLowerCase();});
var sec = total[1];
for(var i=0; i < sec.length; i++){
// console.log(sec[i]);
console.log(total.indexOf(sec[i]));
}
}
mutation(["hello", "hey"]);
I am seeking some clarification on this. Can someone help me with it, please? The line with
console.log(sec[i]);
displays each letter of the 'hey' string one by one in the console. This seems to be working fine. However, I'm puzzled by why calling 'sec[i]' in
console.log(total.indexOf(sec[i]));
always results in outputting '-1', indicating that the .indexOf() method couldn't find any matching letter!