Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //solution 1, using the array method Every()
- function palindrome(str) {
- a = str.split('').every((char, i) => {
- return char === str[str.length - i - 1];
- });
- return a;
- }
- //solution 2, using the array method reverse()
- function palindrome(str) {
- a = str.split('').reverse().join('');
- if (str === a) {
- return true;
- } else {
- return false;
- }
- }
Add Comment
Please, Sign In to add comment