Capitalization of 1st letter of each word of a string

is there any way to solve this code using basic elements of js?
this code is regarding the capitalization of the first letter of each word of a string

*Your code so far


function titleCase(str) {
return str;
}

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

Your browser information:

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

Challenge: Title Case a Sentence

Link to the challenge:

Yes it is perfectly possible
The links bellow might be helpfull for u

function titleCase(str) {
 var splitStr = str.toLowerCase().split(' ');
   for (var i = 0; i < splitStr.length; i++) {
       // You do not need to check if i is larger than splitStr length, as your for does that for you
       // Assign it back to the array
       splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1);     
   }
   // Directly return the joined string
   return splitStr.join(' '); 
}

You can also use regex

1 Like

I have already visited those links but they used lowercase() and many more elements which I haven’t learnt yet
So, it would be very much helpful for me if you could provide me with the simplest way to solve this problem

I don’t understand why do you want the easiest way out here?
Aren’t you here to learn? Learning means stepping out of your comfort zone.

You can try and go the hard route we are here to support for you. :3 post your code a 100 times if you need to. However you will have to make the 1st step yourself here.

Too basic technique. Each letter has an ASCII code, small and capital letter have different code. Do some plus and minus you will be able to solve it. :laughing: :laughing: :laughing: :laughing:

https://theasciicode.com.ar/ascii-printable-characters/capital-letter-z-uppercase-ascii-code-90.html

Thanks for helping me

1 Like

Thanks for helping me.