I have the following array:
const people = [
"JoHn", "ChrISTiana", "anThoNY", "MARia", "jaMeS", "MIChaEl", "jeNNIFeR"
];
I want to capitalise the first letter of each word and lowercase the rest.
I have used the following function to generate a new array:
let capitaliseNames = (arr) => {
return arr.map((item) => item[0].toUpperCase() + item.slice(1).toLowerCase());
};
But how do I mutate the original array? I have tried the same approach but using forEach and it doesn't seem to work.