daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //solution 1, using the array method Every()
  2. function palindrome(str) {
  3.     a = str.split('').every((char, i) => {
  4.         return char === str[str.length - i - 1];
  5.     });
  6.     return a;
  7. }
  8.  
  9. //solution 2, using the array method reverse()
  10. function palindrome(str) {
  11.     a = str.split('').reverse().join('');
  12.     if (str === a) {
  13.         return true;
  14.     } else {
  15.         return false;
  16.     }
  17. }
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
 
Top