title: How can I exclude punctuation in "pig latin" function?
body: <p>I apologize if this question has been answered somewhere - please point me in the right direction if so. I have read through a bunch of solutions and have not yet cracked it!</p>
  
  <p>Sooo...basically, I need to:
  Move the first letter of each word to the end of it, then add "ay" to the end of the word. Leave punctuation marks untouched.</p>
  
  <p>This is my code so far:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function pigIt(str) {
    var newStr = str.split(" ");
  
    var changed = newStr.map(function(input) {
      return input.substring(1) + input.charAt(0) + "ay";
    });
  
    changed = changed.join(" ");
    return changed;
  }
  
  console.log(pigIt('Pig latin is cool'));</code></pre>
  </div>
  </div>
  </p>
  
  <p>As you can see, the code will work for any input that doesn't include punctuation. Great. Now I need to maybe add a Regex somewhere to exclude punctuation but I don't know where to put it! Please help!!</p>