Build a Palindrome Checker Project - Build a Palindrome Checker

Tell us what’s happening:

not sure why the 1 st and second task arent passing there right there on lines 11 & 12 im pretty sure the syntax is right and i double checked the spelling should be right am i missing somthing or is this a bug.

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"> 
<meta name= "viewport" content="width=device-width,intial-sacle=1.0">
<meta http-equiv="X-UA-Compatible" content= "ie=edge">
<title> palindrome checker project</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<input id="text-input">
<button id="check-btn"></button>
<p id ="result"></p>
<script src="script.js"></script>
</body>
</html>
/* file: script.js */
const checkButton = document.getElementById("check-btn");
const textInput = document.getElementById("textInput");
const result = document.getElementBYId("result");
checkButton.addEventListener("click", ()=> {if(textInput.value === "")} alert("please input a value")}
})
/* file: styles.css */

Your browser information:

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

Challenge Information:

Build a Palindrome Checker Project - Build a Palindrome Checker

const textInput = document.getElementById(“textInput”); ← you have no id by that name in the html

isnt that java script code

this is what i tried didnt work preety sure my format was right before

const textinput=document.getElementById("textinput");

also for reference i tried it with th e dash in between text and input

yea i really don’t know i looked up the id tag syntac on line and unless im reading it wrong of the website none of them work .

Hi there! You have the above id attribute value within input element in your html content.

And within the JavaScript DOM assignment, you have "text input".

Also here in getElementById you have Y capitalized.

You have missing the if opening bracket.

The alert() method should be between the if {} body.

im confused in your post concerning missing the if opening bracket the opening bracket should be in front of the the if an example being {if however i n your next post you say the alert method should be between the if and the body {} indicatating there are two opening brackets right ?

Example of if statement:

if (condition) {
// Your code 
}

Indent your code properly and compare your if statement with the above example.

Remember, your are coding JavaScript, not writing letters to anyone. Don’t mind.

not sure why but step 10 wont pass the logic looks right

I can’t see, what you did to your code.

sorry

const checkButton = document.getElementById("check-btn");
const textInput = document.getElementById("text-input");
const resultDiv = document.getElementById("result");
checkButton.addEventListener("click", () => {
  const inputValue = textInput.value.toLowerCase();
if (inputValue === ""){
  alert("Please input a value");
  } else if (inputValue === "a") {
resultDiv.textContent
 ="A is a palindrome";
} else if (inputValue=== "eye") {
  resultDiv.textContent = "eye is a palindrome";
} else if ( inputValue === "_eye"){
resultDiv.textContent = "_eye is a palindrome";
} else if (inputValue === "race car"){
  resultDiv.textContent = "race car is a palindrome";
} else if (inputValue === "not a palindrome"){
  resultDiv.textContent = "not a palindrome is not a palindrome";} else if (inputValue === "A man, a plan, a canal. panama"){
  resultDiv.textContent = "A man, a plan, a canal. Panama is a palindrome"
  } else{resultDiv.textContent = "";
    }
});

You can’t hard code the functionality for checking palindrome. You need to utilize a function that can check for palindrome. Your palindrome should check anything whatever the user type in the input.

so i took out all the hardcoding and now nothing past step 4 passes

const checkButton = document.getElementById("check-btn");
  const textInput = document.getElementById("text-input");
  const resultDiv = document.getElementById("result");
  checkButton.addEventListener("click", () => {
  const inputValue = textInput.value;
  const cleanedInput = inputValue.toLowerCase().replace(/[^a-z0-9]/g, '');
  const reversedInput = cleanedInput.split('').reverse().join('');
  if (inputValue === ""){
    alert("Please input a value ");
    } else if (cleanedInput === reversedInput){
      resultDiv.textContent = `"${inputValue}" is a palindrome`;
    }else {resultDiv.textContent =`"${inputValue}" is not a palindrome`;
      }
  });

Remove quote marks around the variable ${inputValue}