Last active
April 19, 2021 09:21
-
-
Save darshna09/68591b2168f302d122e16421ee439e2c to your computer and use it in GitHub Desktop.
Check if the given word is a palindrome or not.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {string} word | |
* @return {boolean} | |
* true if palindrome else false | |
*/ | |
function isPalindrome (word) { | |
if (word) { | |
return word.toLowerCase() === word.toLowerCase().split('').reverse().join('') ? true : false; | |
} else { | |
return false; | |
} | |
} | |
isPalindrome('radar'); // true | |
isPalindrome('RadAr'); // true | |
isPalindrome('No'); // false | |
isPalindrome(); // false | |
isPalindrome('#$#'); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment