Basic Algorithm Scripting - Title Case a Sentence

Code does everything right but it won’t let me finish the chellange.

function titleCase(str) {
  let result = ""
  let splited = str.split(" ")
  let word = ""

  for(let i = 0; i < splited.length; i++ ) {
  let l = splited[i].slice(1).toLowerCase()
  let u = splited[i][0].toUpperCase()

    word = u + l
    result += " " + word
     return result


console.log(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT"));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic Algorithm Scripting - Title Case a Sentence

Link to the challenge:

You are not returning the exact same string as the excercise asks, spaces do matter!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.