Last active
September 5, 2019 04:23
-
-
Save rakin92/a35ea7135f740a2d2ff97943b61a755a to your computer and use it in GitHub Desktop.
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
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