SHARE
TWEET

Untitled

a guest Mar 26th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function palindrome(str) {
  2.   let pat = new RegExp("[a-z0-9]");
  3.   let newStr = str.toLowerCase().split("").filter(x => pat.test(x));
  4.   let testStr = newStr.join('');
  5.   let reverseStr = newStr.reverse().join('');
  6.   console.log(testStr);
  7.   console.log(reverseStr);
  8.   if(testStr === reverseStr){
  9.     return true;
  10.   }
  11.   // Good luck!
  12.   return false;
  13. }
  14.  
  15.  
  16.  
  17. palindrome("eye");
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top