title: JavaScript: How would I reverse ONLY the words in a string
body: <p>How would i write a function that takes one argument that is a sentence and returns a new sentence where all words are reversed but kept in the same order as  the original sentence?</p>
  <p>Test Case:</p>
  <pre><code>wordsReverser(&quot;This is fun, hopefully.&quot;);
  </code></pre>
  <p>Would return:</p>
  <pre><code>&quot;sihT si nuf, yllufepoh.&quot;
  </code></pre>
  <p>This is what I have so far but notice that I cant get the period and comma to stay in place. I don't know if this was a typo by the interviewer or what?</p>
  <pre><code>function wordsReverser(str){
    return str.split(' ').
      map(function(item) {    
          return item.split('').reverse().join('');
      }).join(' ');
  }
  
  wordsReverser(&quot;This is fun, hopefully.&quot;);
  //Output: 'sihT si ,nuf .yllufepoh'
  </code></pre>