KoduFCC
November 23, 2024, 11:14pm
1
Tell us what’s happening:
I’m stuck. Here’s the pseudo code:
for (var i = 0, i < str.length, i++) {
str.split();
word[0].toUpperCase;
word[1,…].toLowerCase;
}
Your code so far
function titleCase(str) {
for (let i = 0; i < str.length; i++) {
str.split();
}
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/131.0.0.0 Safari/537.36
Challenge Information:
Basic Algorithm Scripting - Title Case a Sentence
First convert the all the characters into lower case with “toLowerCase” function.
Then refer to the following article from freecodecamp for the rest of the steps.
By Catalin Pit In this article, you are going to learn how to capitalize the first letter of any word in JavaScript. After that, you are going to capitalize the first letter of all words from a sentence. The beautiful thing about programming is that...
Teller
November 24, 2024, 2:53am
3
Hi @KoduFCC
There are two parts to this exercise.
Part 1 is to capitalise the first letter of each word.
Part 2 is to lowercase the remaining letters of each word.
To help you along, place the function call in a console.log()
so you can see what the function is returning.
Happy coding
KoduFCC
November 24, 2024, 11:27pm
4
I know, but I used the split method. I wanted to confirm if that method is correct or if I need to use a different method, and which one I need to use.
Teller
November 25, 2024, 12:57am
5
With programming, there may ways to solve a problem.
For this one you could use a loop or another method.
Write down in words what you need to do for each part or section, then test out with your code.
Happy coding