/*
A palindrome is a word, number, phrase, or other sequence of symbols that reads the same backwards as forwards
*/
function isPalindrome(word) {
word = word.toLowerCase().replace(/[^a-z0-9]/g, '');
console.log("Word", word);
return (word.split('').reverse().join('') == word) ? true : false;
}
console.log("IsPalindrome ", isPalindrome("m A d aMS"))
No comments:
Post a Comment