I don’t currently want any help attaining the answer to the actual project, but I do want to know why it is displaying and empty array and then an uppercase J, if anyone knows.
function titleCase (title) {
title = title.toLowerCase();
title = title.split(" ");
for (let i = 0; i < title.length; i++) {
title[i] = title[i].split("");
}
let firstLetter = [];
for (let i = 0; i < title.length; i++) {
console.log(firstLetter);
firstLetter.splice(0, 1, title[i][0]);
firstLetter = firstLetter[0].toUpperCase();
}
return title
}
titleCase("Jimmy blah blah blah.");
no, .toUpperCase() does not turn firstLetter into a string.
what makes it a string is when you assign firstLetter a new value in this line, instead of assigning the value to an element which is stored insidefirstLetter