Tell us what’s happening:
Please can somebody tell me what am I doing wrong here?
**Your code so far**
function stringWithOnlyAlphanumeric(str) {
//Replace takes regex and a replacemnt string
return str.replace(/[\W_]/gi, "");
}
console.log(stringWithOnlyAlphanumeric("Hello, world!@# Iam happy to be here !!!!!!"));
function stringLowercased(str) {
return str.toLowerCase();
}
const stringReversed = (str) => {
let result = "";
for (let i=str.lenght-1; i >= 0; i--) {
result += str[i];
}
return result;
}
console.log(stringReversed("Hello"));
function palindrome(str) {
//Remove non-alphanumeric characters
const cleanedUpStr = stringWithOnlyAlphanumeric(str);
//Making string lowercase
const lowercaseStr = stringLowercased(cleanedUpStr);
//Reverse the String
const reversedStr = stringReversed(lowercaseStr);
//Return the conparison of:
//Reversed string equals to lowercase cleaned up string
console.log(`Is "${lowercaseStr}" equals to "${reversedStr}"?`)
return lowercaseStr == reversedStr;
}
//These are palindromes
//Tenet
//Hannah
//tacocat
console.log(palindrome("eye"));
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36
Challenge: Palindrome Checker
Link to the challenge: