I commented out line 14, because it does work properly. My intention was to remove an item from the array based on str [i], but it does not work properly.
Could you please help me to remove letters which were capitalized later? Cheers!
Wow. Seems to me you might want to rethink your strategy. You’re going through letter-by-letter, when you may not really need to. You know a couple of things:
- you’ll get a string of words, possibly of mixed case.
- for EACH word, the first letter should be upper case.
- for EACH word, the rest of the letters should be lower case.
- you will return a string, containing each word with the above modifications.
Does this indicate something? Perhaps splitting the string into an array of words, then doing something with each word individually?
Another strategy would be to split the array into words, then for each word process them separately.
As this is not a final challenge, I don’t mind sharing the code I put together for this, if you think it might help. Take a look at this repl.
Thank you. I will try this way also.
This is an interesting approach. I will try to write the code based on your steps.
Here’s a strategy. You’ll want to break a sentence into an array of words and go over each word. You want to make sure the first letter is uppercase and the rest of the letters are not.
Hint: String.prototype.split() and String.prototype.substring()
String.replace() is also a fun option.