Title Case a Sentence - Solution not working

Tell us what’s happening:
Ignore the fact that i’m console.log ging instead of returning, i did that just for debugging. my For loop, in particular, doesn’t seem to have any effect. i know the mistake is in there somewhere, but i keep looking at it but can’t figure it out.

Your code so far

function titleCase(str) {
  let wordArr = str.split(" ");
  for (let i = 0; i < wordArr.length; i++){
  console.log(wordArr.join(" "));

titleCase("sHoRt AnD sToUt")

Your browser information:

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

Link to the challenge:

Strings are immutable, meaning you can’t directly modify them using bracket notations. You have read access but nothing else.

You could do 2 things.
You could convert it to an array and do the operations or use slice methods to replace entire strings using concatenations.

Good luck!

1 Like