Skip to content

Instantly share code, notes, and snippets.

View Heks0's full-sized avatar

Ebrahem___ Heks0

View GitHub Profile
@tianmingzuo
tianmingzuo / palindromeChecker2.js
Created October 14, 2019 01:59
Palindrome Checker: Return true if the given string is a palindrome. Otherwise, return false. A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing. Note You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything into the …
function palindrome(str) {
// Good luck!
let newStr = str.replace(/\W|_/g, '');
newStr = newStr.toLowerCase();
let revStr = newStr.split('').reverse().join('');
if(newStr === revStr){
return true;
}
return false;
}