I'm through with the palindrome project. The app is totally functional, but the user story 5-19 can't pass. What could be the cause? What should I do? Thanks!

Hi everyone, I feel accomplished today, being able to persist to the end of the of the last certification project on Responsive Web Design

Hi. Let’s see if I can help.
Start by giving as much info about your problem, and share your code and error logs.

here’s the script:
const checkBtn = document.getElementById(‘check-btn’);
checkBtn.addEventListener(‘click’, checkPalindrome);

function checkPalindrome(){
const textInput = document.getElementById(‘text-input’).value;

if(textInput === ""){
    alert("Please input a value");
    return;
}

const cleanedString = textInput.replace(/[^a-zA-Z0-9]/g, '').toLowerCase();
const isPalindrome = cleanedString === cleanedString.split('').reverse().join('');
const result = document.getElementById('result');

if (isPalindrome){
    result.textContent = `Yes, "${textInput}" is  a PALINDROME!`;
    result.style.color = '#90ee90';
} else{
    result.textContent = `No, "${textInput}" is NOT a palindrome!`;
    result.style.color = 'red';
}

}

Hi. The text needs to be exact. Follow the wording in the stories exactly for how it should appear for both true / false cases.

Does your button work when you input text into the HTML? If not you need to add something to make the button functional.

If this still doesn’t work after correcting that can you please post all your HTML and javascript code with 3 backticks before and after each code block. Many thanks

2 Likes

The code looks fine, but as @a1legalfreelance suggested, the test could still fail if you didn’t do it exactly as asked, verbatim. The code might work, but these exercises are also a good way to practice following precise instructions.

Please, when you add code to your comments, look at your comment after submitting it, and make sure the code is actually inside the code block of your comment. If not, edit and clean it up so it’s easier to read.

Finally, it helps a lot if you include a link to the problem itself, so we can read for other things that you might not have considered relevant, but actually are.

1 Like

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge. This button only appears if you have tried to submit an answer at least three times.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

1 Like

Thanks. The button is working and the app ultra functional. And as you said, the exercises are a good way to practice following precise instructions. Maybe I’m yet to understand exactly what they want.
But in the meantime, I’m gonna have to move on to another topic/project, and by the time I’m ready to claim my certification, my understanding will have deeper, and I strongly believe that I’ll be able to sort it out.
I did same before eventually claiming my Responsive Web Design Certification.

I sincerely appreciate your reply.

Okay. Thank you very much. I’ll be doing that as well.

Yeah. The button is working every well. Thank much.