Skip to content

Instantly share code, notes, and snippets.

@imgsrc
Last active August 23, 2018 18:31
Show Gist options
  • Save imgsrc/ccb856c6ff514ee2213d5c3cbaaede92 to your computer and use it in GitHub Desktop.
Save imgsrc/ccb856c6ff514ee2213d5c3cbaaede92 to your computer and use it in GitHub Desktop.
isPalindrom
isPalindrome("racecar"); // true
isPalindrome("race Car"); // true
function isPalindrome(word) {
// Уберём все символы, не являющиеся буквами
var lettersOnly = word.toLowerCase().replace(/\s/g, "");
// Сравним строку с её перевёрнутой версией
return lettersOnly === lettersOnly.split("").reverse().join("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment