Help in a challenge

Hey guys, its my first time using the forum, so …sorry if i do something wrong here ^^

I tried to understand how the algorithm of this challenge works seeing the answer in the tips page, but i can’t do it, especially when(in the solution 1) they use “for (var st in newTitle)”

Can someone help me to understand this challenge please?

Challenge: Title Case a Sentence

Link to the challenge:

It’s generally expected that you show us the code you have tried so far so we can help you fix any errors. When you are on the challenge, click the “Get Help” button and then “Ask for Help”. This will allow you to create a new thread and will automatically include your current code.

Since you have already created the thread you will just need to paste your code in here. Make sure to put three backticks in a row on a line by itself, then paste your code underneath those backticks, then put another three backticks below your code.

1 Like

Often, when faced with a challenge that makes little to no sense, I will slow down and break it into smaller bite-size pieces. This is one of those times.

You are being asked to “title case a sentence.” What does this mean? Each word should be in a consistent case, with the first letter capital and the rest of the word lower.

So look at that last sentence. There’s a bite-sized piece in there: How can I capitalize the first letter of a word, and lowercase the rest of that word?

You are no longer focusing on the larger problem of “how can I make this sentence title-case,” you’re now looking at one small part - can I capitalize a word?

If you can figure out how (hint: if you can write a function to…), then you look at the next bit - can you come up with a way to break a given string into words, and then apply that same methodology to each word?

that’s really the essence of development work: given a big problem I can’t fully grok, break it down into bite-size bits, tenderize 'em, andd throw 'em into the soup. :wink:

1 Like