Guest User

Untitled

a guest
Sep 14th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment