title: JavaScript - Find if string is a palindrome - Check for punctuation
body: <p>I am trying to solve an exercise but the code shows errors. Here are the conditions given for the exercise:</p>
  
  <blockquote>
    <p>Return true if the given string is a palindrome. Otherwise, return false.</p>
    
    <ol>
    <li>You'll need to remove punctuation and turn everything lower case in
    order to check for palindromes.</li>
    <li>We'll pass strings with varying formats, such as "racecar",
        "RaceCar", and "race CAR" among others.</li>
    </ol>
  </blockquote>
  
  <p>My attempt:</p>
  
  <pre><code>function palindrome(str) {
      str = str.toLowerCase();
      str = str.replace(",", "");
      str = str.replace(".", "");
      str = str.replace(":", "");
      str = str.replace(";", "");
      str = str.replace("-", "");
      str = str.replace(",", "");
      str = str.replace(" ", "");
      for (var i = 0; i &lt;= (str.length / 2); i++) {
          if (str[i] != str.length - i) return false;
      }
      return true;
  }
  </code></pre>