Build a Palindrome Checker Project - Build a Palindrome Checker

I merged your threads. Please do not create new threads for the same question. Thank you.

Read the post above your latest post.

Hey Lasjorg,
my sincere apology! Thanks for the update as well!

  1. Add a click handler to the button. You can call the palindrome function using onclick="palindrome()" on the button.

  2. Inside the palindrome function, instead of using the str parameter, get the text from the value property of the textInput element and use that.

  3. Instead of returning true and false update the result elements text content with the required text.

  4. Validate your code works with all the test cases.

  5. Handle an empty input as required.

Hi @hiekamara1

You have a typo in your code.

Happy coding

1 Like

Thanks Teller, Just clarified the typo! Still at work with my test!

1 Like

Keep up the progress. The first one is the most challenging. The one I did took nearly two weeks. If you find yourself not making any progress, take a one or two day break. It can also help to write down in words what you want the code to do. Identify knowledge gaps, then just Google if a method or way of coding exists.

Happy coding

1 Like

I definitely believe you Teller, but I will keep trying everyday for an hour or two. I don’t mind how much difficulty I am experiencing for now but, I will figure out what I am actually missing!

I have started my life many times over and over again in new directions! All the time I arrived at a New Beginning Point, it was always difficult like the test I am having tough time with now but, I never allowed my obstacle to be my setback .
@lasjorg @JeremyLT @jwilkins.oboe
I am grateful to have you guy here as guidance and supporters. Billions of people in the next years to come will be a professional coder because of you guys! I thank you guys for the motivation and courage. Means a lot.

will come back tomorrow again and research and try another method!

1 Like

Hi Easside, I think you are really close! But I think you should review how we pull up html elements by id:

Also, check your last line regarding what happens when you press the button.

1 Like

Just remember querySelector takes a CSS selector, it only knows what element it is looking for by the selector specifying it.

Unlike say getElementById which only can look for ids (so # is not needed).

1 Like

Which tests are failing?

  1. Don’t invoke () the isPalindrome callback function. You should pass it just the identifier isPalindrome so that when the event triggers it calls the callback function.
buttonCheck.addEventListener("click", isPalindrome());

  1. The variables you are using in the code are not the ones containing the elements.
const textInput = document.querySelector("#text-input");
const checkBtn = document.querySelector("#check-btn");
const result = document.querySelector("#result");

textInput not inputText
checkBtn not buttonCheck


  1. string is not the correct name, it is capital S String(). You can technically do what you are doing, stringifying arrays and comparing them but I’m not sure I would suggest doing that. But it does work in this case so up to you.

  1. You are missing an space between the input value and the string in the result output.
1 Like

Hi @hiekamara1

Just had a quick glance at your code.

Add a single space before the word is in the string.

Happy coding

1 Like

How does the function button alert get called?

1 Like

By adding it to the Event Listener!

Thanks guys! I just pass one of the test. While is true, I have the remaining test to pass and complete the challenge, I am really grateful for all of the helps! means much to me! :pray:

1 Like

I don’t think these functions should exist. You’re trying to hardcore the answer, which is a no-no

Hey JeremyLT,
Thanks for your quick reply! I don’t understanding what do mean by hardcore the answer? Can you please elaborate in a bit detail on my codes!

There are different texts given in the Test to check if they are Palindrome or not a Palindrome. That is why I created different functions to enter the respective text as given in the instruction.

if these functions should not exist, can you please give me a clearer hint! I felt all the Texts to be check needed a specific function

The functions definitely should not exist. The hint is to delete them. Your buttonAlertand isPalindrome code should handle all those cases without separate functions.

1 Like

One more question please! Can I use statement like in the buttonAlert to enter the rest of the text to be check and call isPalindrome ?

This logic seems good to me

1 Like