Am I in the right direction?

Tell us what’s happening:
I reached myself this solution so far by reading the hints.
Could you please check and help me with hints? I defined 2 steps but happy to work on more needed ones.
Thanks in advance!

Your code so far

function titleCase(str) {
  //1.Return the str with the first letter of each word capitalised 
for(let i = 0; i >= str.length; i++) {
return str[i].split("").toLowerCase(str).toUpperCase(str)

}
  return str;
}

titleCase("I'm a little tea pot");

function titleCase(str) {
//1.Return the str with the first letter of each word capitalised 
for(let i = 0; i >= str.length; i++) {
return str[i].split("").toLowerCase(str).toUpperCase(str)

}
return str;
}

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/83.0.4103.61 Safari/537.36.

Challenge: Title Case a Sentence

Link to the challenge:

split string into spaces-(" ") and work on the words array, then you easily can capitilize each array member’s first letter .

A couple of things I notice.

This line means your for loop will never run. Your for loop will only run when i is greater than or equal to str.length, and since i is initialised with a value of 0, the loop doesn’t run.

What are you trying to accomplish with this line?
str[i] gets the character from str at position i.
split("") tries to turn that character into an array?
.toLowerCase(str) is incorrect syntax. .toLowerCase() does not take arguments.
.toUpperCase(str) is also incorrect syntax. Assuming these two were written correctly, you’d be turning the string to lower case and back to upper case?

Regarding your last question, yes, it is advised first to make the word lower case and then convert to Upper case.
Will adjust the foor loop.
I am trying to solve this challenge but I cant work out the syntax

The challenge asks for the first letter to be upper case and the rest to be lower case.
Why would you convert the entire word to lower case and then convert the entire word to upper case?

It says on the hints, number 2 hint , please can you read it? I am confused :frowning:

You should make the word lowercase before making the first letter uppercase

The key here is “first letter uppercase” :slight_smile:

Thank you.
so first str.toLowerCase()