title: Assistance with javascript palindrome
body: <p>I am trying to solve a palindrome using a <code>for</code> loop in JavaScript (my code is below).</p>
  <p>I cannot figure out what I am doing wrong. If someone can please correct and explain, it will be much appreciated. I am fairly new to coding.</p>
  <pre><code>var word = window.prompt(&quot;Enter a word&quot;);
  function palindrome(a) {
    var reversed = '';
    for (i = 0; i &lt;= a.length; i++) {
      reversed = reversed + a[a.length - 1 - i];
    }
    if (a == reversed) {
      return &quot;true&quot;;
    } else {
      return &quot;false&quot;;
    }
  }
  document.write(palindrome(word));
  </code></pre>