Removing backslash out of my string

I am doing the Title Case a String challenge, and my final code is outputting (I can’t get the backslash to show, but it’s in the word “I’m) ‘I’m a little tea pot’, which won’t pass the test due to the slash. I’ve tried googling how to remove it. I’m getting things like adding “.replace(”\/g”, “”)", but for one, I dont really understand the syntax, and also it’s not working. Any help is appreciated.

function titleCase(str) {
  let words = str.split(" ");
  for (var i=0; i<words.length; i++){
    words[i][0].toUpperCase();
  };
  let finished = words.join(" ");
  return finished;
}

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


I assume you are using Node to test your code? That \' is not what is causing your code to fail. That ’ signifies there is a literal single quotation mark there. The reason your code fails, is that your function returns ‘I\’m a little tea pot’ instead of ‘I\’m A Little Tea Pot’

Oh man, I feel like an idiot haha. Back to the drawing board, thanks.

You were hoping the above line would make the first letter of each word capitalized. The problem is strings are immutable, so you can not arbitrarily change a character of an existing string. That being said, you could concatenate the result of what you wrote above with the remainder of word[i] and assign it back to word[i]. Just keep in mind, that the remainder of the word should be all lower case.