Skip to content

Instantly share code, notes, and snippets.

@rakin92
Last active September 5, 2019 04:23
Show Gist options
  • Save rakin92/a35ea7135f740a2d2ff97943b61a755a to your computer and use it in GitHub Desktop.
Save rakin92/a35ea7135f740a2d2ff97943b61a755a to your computer and use it in GitHub Desktop.
function isPalindrome(text) {
const reversedText = text.toLowerCase()
.split('').reverse().join('')
return text === reversedText
}
console.log(palindromeChecker('racecar'));
console.log(palindromeChecker('notapalindrome'));
function isPalindrome(text) {
let textLen = text.length;
for (let i = 0; i < textLen/2; i++) {
if (text[i] !== text[textLen - 1 - i]) {
return false;
}
}
return true;
}
console.log(palindromeChecker('racecar'));
console.log(palindromeChecker('notapalindrome'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment