Skip to content

Instantly share code, notes, and snippets.

@kyleplo
Created April 14, 2021 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyleplo/ff7b974bb099937ab7cf6f670762fcf1 to your computer and use it in GitHub Desktop.
Save kyleplo/ff7b974bb099937ab7cf6f670762fcf1 to your computer and use it in GitHub Desktop.
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