a guest Feb 19th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function palindrome(str) {
  2.   // Convert input string to lower case
  3.   // remove special characters
  4.   var original = str.toLowerCase().replace(/\s/g, '').replace(/[^a-zA-Z0-9]/g, '');
  5.   // split string into characters
  6.   // reverse cleaned created array and join to string
  7.   var reverseStr = original.split('').reverse().join('');
  8.   // check if original string equals reversed string
  9.   return original === reverseStr;
  10. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand