Created
April 14, 2021 13:25
-
-
Save kyleplo/ff7b974bb099937ab7cf6f670762fcf1 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
String.prototype.isPalindrome = function (){ | |
if(this.length % 2 === 0){ | |
return this.slice(0, (this.length / 2)) === this.slice((this.length / 2)).split("").reverse().join(""); | |
}else{ | |
return (this.slice(0, Math.floor(this.length / 2)) === this.slice(Math.ceil(this.length / 2)).split("").reverse().join("")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment