Stop right there. Do not look for other’s solutions to this project. This should be your own work. You will learn much more if you do this on your own.
It feels like you don’t quite understand what your code is doing and you are trying to google for quick answers instead of figuring it out. Before you can code a solution, you have to know what you want the code to do. Please explain in English, not code, what the following code is supposed to do.
checkBtn.onclick = () => {
if (value) {
const cleanValue = value.replace(/[^A-Za-z0-9]/g).toLowerCase()
const reversedValue = cleanValue.split('').reverse().join('').toLowerCase()
if(cleanValue === reversedValue){
result.innerText = `${value} is a palindrome`
console.log(cleanValue)
console.log(reversedValue)
} else{
result.innerHTML = `${value} is not a palindrome`;
console.log(cleanValue)
console.log(reversedValue)
}
} else {
alert("Please input a value")
}
}
This is probably going to be the last time I ask unless you answer the question I am asking. It’s nothing personal. I’ve spent quite a bit of time with you on this and maybe I am not the best person to help you?
In my last post, I asked you to explain what your code is doing. I am not convinced that you understand your own code. Until you do that, you won’t be able to solve this project. So please, explain in words what your code is doing.
You are not supposed to copy code from anywhere on this.
You need to write your own code representing how you would solve this problem yourself.
It seems like you may have copied this code. Note that copying code for the certification projects is against the academic honestly agreement and invalidates your certification.
But the reason why I am suggesting to go through those is because they are small problem solving exercises that will help you fill in the gaps on how to break a problem down into pieces and solve it
which is the required skill you need to solve this palindrome checker project as well as the other projects
I think it should work with the button element similar to what I learnt in the Building of the role playing game : using the query selector and the onclick