title: Javascript map method on array of string elements
body: <p>I am trying to understand how to implement the map method (rather than using a for loop) to check a string for palindromes and return boolean values for whether the mapped array elements reversed are the same as the original array elements. I cannot seem to understand the syntax of the map method. How do I get the map to function on each element in the original array? What is the value? Here is my working code, which is only logging a value of undefined:</p>
  
  <pre><code>function palindromeChecker(string) {
      var myString = string.toLowerCase();
      var myArray = myString.split(" ");
      var newArray = myArray.map(function (item) {
          item.split("").reverse().join("");
          return newArray === myArray;
      });
  }
  
  console.log(palindromeChecker("What pop did dad Drink today"));
  </code></pre>
  
  <p>Here is a link to the fiddle:
  <a href="https://jsfiddle.net/minditorrey/3s6uqxrh/1/" rel="noreferrer">https://jsfiddle.net/minditorrey/3s6uqxrh/1/</a></p>
  
  <p>There is one related question here:</p>
  
  <p><a href="https://stackoverflow.com/questions/23622778/javascript-array-map-method-callback-parameters">Javascript array map method callback parameters</a></p>
  
  <p>but it doesn't answer my confusion about the syntax of the map method when using it to perform a function on an array of strings.</p>