Build a Title Case Converter - Build a Title Case Converter

Tell us what’s happening:

const titleCase = (string) => {

let lowcaseString = string.toLowerCase().split(" ")

let casedString = “”

for
(let x = 0; x < lowcaseString.length; x++)

{

casedString += lowcaseString[0].toUpperCase() + lowcaseString.substring(1) + " "
}

return casedString
}

Not sure what am doing wrong?

Your code so far

const titleCase = (string) => {

let lowcaseString = string.toLowerCase().split(" ")


let casedString = ""



for 
(let x = 0; x < lowcaseString.length; x++)

{

casedString += lowcaseString[x][0].toUpperCase() + lowcaseString[x].substring(1) + " "
}

return casedString
}

console.log(titleCase("I'm a little tea pot"))



Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0

Challenge Information:

Build a Title Case Converter - Build a Title Case Converter

I suggest you print it like this console.log(JSON.stringify(titleCase("I'm a little tea pot")))

it will show you the issue more clearly