JS White’s Problem

  node.js, question
function titleCase(str) {
 str = str.toLowerCase().split(' ')
 
 The difference between. map (word) {//is here.
 Return (word.charat (0). touppercase () plus word.slice(1));
 })
 return str.join(' ');
 bracket
 console.log(titleCase("I'm a little tea pot"));
function titleCase(str) {
 str = str.toLowerCase().split(' ');
 
 This is the difference between str.map (word)
 Return (word.charat (0). touppercase () plus word.slice(1));
 })
 return str.join(' ');
 bracket
 console.log(titleCase("I'm a little tea pot"));

Why can the first code take the map function? However, the second one did not, it was just an assignment to str. Why didn’t it take effect?

function titleCase(str) {
 str = str.toLowerCase().split(' ');
 
 The difference between str = str.map (word) {//is here.
 Return (word.charat (0). touppercase () plus word.slice(1));
 })
 return str.join(' ');
 bracket
 console.log(titleCase("I'm a little tea pot"));