Build a Palindrome Checker Project - Build a Palindrome Checker

I keep trying but its not working

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Palindrome Checker</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
  <main class="container">
    <h1>Palindrome Checker</h1>
    <label for="text-input">Enter in text to check for a palindrome:</label>
    <input id="text-input" required>
    <button id="check-btn">check</button>
    <div id="result"></div>
  </main>
  <script src="script.js"></script>
</body>
/* file: styles.css */
*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'poppins', sans-serif;
}

body{
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: skyblue;
}
.container{
  background: #eee;
  max-width: 500px;
}
/* file: script.js */
const textInput = document.getElementById("text-input");
const checkButton = document.getElementById("check-btn");
const result = document.getElementById("result");

checkButton.addEventListener("click", () => {
  if (textInput !== "") {
    alert("Please input a value");
  } else {
    const originalText = textInput.value.toLowerCase().replace(/a-zA-z/g, "")
    const reverseText = originalText
    .split()
    .reverse();

   //palchecker = (originalText, reverseText, textInput.value); 
  }
}
)

const palindromeChecker = (textInput, reverse, original) => {
  if (textInput !== reverse) {
    result.textContent = `${originalText} is a palindrome`;
    return true;
  } else {
    result.textContent = `${originalText} is not a palindrome`;
    return false;
  }
}

palindromeChecker()

Your browser information:

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

Challenge Information:

Build a Palindrome Checker Project - Build a Palindrome Checker

You have a couple of issues in JS: there are two greyed out variables and/or params which means they are probably unassigned and the second is your value property is coming in as misspelled-not sure what this means here. Finally the js from FCC`s app works, you may want to look at it if all else fails. Good luck

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.