Can someone explain to me why this solution works. “L” is never defined. At what point is it understood that L == first letter?
function titleCase(str) {
return str.toLowerCase().replace(/(^|\s)\S/g, L => L.toUpperCase());
}
function titleCase(str) {
return str.toLowerCase().replace(/(^|\s)\S/g, word => word.toUpperCase());
}
console.log (titleCase("I'm a little tea pot"));
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36
.
Challenge: Title Case a Sentence
Link to the challenge: