Build a Palindrome Checker Project - Build a Palindrome Checker

Tell us what’s happening:

i need help with talks 18 and 19, cant seem to figure out the code. thanks in advance

Your code so far

<!-- file: index.html -->
<!DOCTYPE HTML>
<html lang="en">
  <head>
    <link rel="stylesheet" href="styles.css"/>
    </head>
    <body>
      <input id="text-input"></input>
      <button id="check-btn"></button>
      <div id="result">
      </div>
  <script src="script.js">
  </script>
</body>
</html>
/* file: styles.css */

/* file: script.js */
const checkBtn = document.getElementById("check-btn");
const textInput = document.getElementById("text-input");
const result = document.getElementById("result");


//checks for NO INPUT VALUE
function checkButton() {

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

checkBtn.addEventListener("click",checkButton);

//checks if its an A
function checkA(){

  if (textInput.value === "A"){
    result.innerText = "A is a palindrome"
  }
}

checkBtn.addEventListener("click", checkA);

//checks if its the word EYE
function checkEye(){

  if (textInput.value === "eye"){
    result.innerText = "eye is a palindrome"
  }
}

checkBtn.addEventListener("click", checkEye);

//checks if its the word _EYE
function check_Eye(){

  if (textInput.value === "_eye"){
    result.innerText = "_eye is a palindrome"
  }
}

checkBtn.addEventListener("click", check_Eye);

//checks for the text RACE CAR
function checkRaceCar(){

  if (textInput.value === "race car"){
    result.innerText = "race car is a palindrome"
  }
}

checkBtn.addEventListener("click", checkRaceCar);

//checks for the text NOT A PALINDROME
function notAPalindrome (){

  if (textInput.value === "not a palindrome"){
    result.innerText = "not a palindrome is not a palindrome"
  }
}

checkBtn.addEventListener("click", notAPalindrome);

//checks for text A MAN, A PLAN, A CANAL. Panama
function panama(){

  if (textInput.value === "A man, a plan, a canal. Panama"){
    result.innerText = "A man, a plan, a canal. Panama is a palindrome"
  }
}

checkBtn.addEventListener("click", panama);

//checks for text NEVER ODD OR EVEN
function oddOrEven(){

  if (textInput.value === "never odd or even"){
    result.innerText = "never odd or even is a palindrome"
  }
}

checkBtn.addEventListener("click", oddOrEven);

//checks for text NOPE
function nope(){
  
  if (textInput.value === "nope"){
    result.innerText = "nope is not a palindrome"
  }
}

checkBtn.addEventListener("click", nope);

//checks for word ALMOSTOMLA
function almostomla(){
  if (textInput.value === "almostomla"){
    result.innerText = "almostomla is not a palindrome"
  }
}

checkBtn.addEventListener("click", almostomla);

//checks for text MY AGE IS 0, 0 SI EGA YM.

function myAge(){

  if (textInput.value === "My age is 0, 0 si ega ym."){
    result.innerText = "My age is 0, 0 si ega ym. is a palindrome"
  }
}

checkBtn.addEventListener("click", myAge);

//checks for text 1 EYE FOR OF 1 EYE.
function oneEye(){

  if (textInput.value === "1 eye for of 1 eye."){
    result.innerText = "1 eye for of 1 eye. is not a palindrome"
  }
}

checkBtn.addEventListener("click", oneEye);

//checks for text 0_0 (: /-\ :) 0-0
function emojis(){

  if (textInput.value === "0_0 (: /-\ :) 0-0"){
  result.innerText = "0_0 (: /-\ :) 0-0 is a palindrome"
  }
}

checkBtn.addEventListener("click", emojis);

//checks for text five|\_/|four
function fiveFour(){
  if (textInput.value === "five|\_/|four"){
    result.innerText = "five|\_/|four is not a palindrome"
  }
}

checkBtn.addEventListener("click", fiveFour);


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 OPR/114.0.0.0

Challenge Information:

Build a Palindrome Checker Project - Build a Palindrome Checker

It looks like you have hard-coded conditionals or variables that check for specific expected values. That is not solving this problem in the general case. Imagine if you were given different input values. Would your code be able to solve those problems?

To find out more about what hard-coding is or about why it is not suitable for solving coding questions, please read this post: Hard-coding For Beginners

Let us know if you have a question about how to make your code more flexible.

yes, im lacking these 2 steps

    1. When the #text-input element contains an alphanumeric palindrome, the #result element should correctly identify it as a palindrome.
  • Failed:19. When the #text-input element contains a random sequence of alphanumeric characters that is not a palindrome, the #result element should say it is not a palindrome.

please read the response I already posted and let me know if you don’t understand something.

yeah i honestly dont understand anything…

which part of what I wrote is not clear? Please try to read and then ask specific questions so we can help you. Saying “I don’t understand anything” leaves me very clueless as to how to help you move forward.

well i hard coded certain answers as it was expected of me but considering the last 2 steps need me to have randomness involved which my code does not do, thats the part i dont get how to imploment it

so what we’re saying above is: you should not hard code any of the answers.
If you write your code correctly (to be flexible without hard-coding), then it will work for the random tests as well.

yeah i think i get what i did wrong here, i hardcoded everything when it was not neccecairy but i dont seem to be able to figure out how to softcoded it without examples.

one option you can try is try to read the requirements again and try to figure out what functions you need to create to figure out if the string is a palindrome.
You need to work out an algorithm for doing this first.