Build a Palindrome Checker Project - Build a Palindrome Checker

Tell us what’s happening:

I’m having a lot of trouble figuring JavaScript out. I’ve been trying to just get the first palindrome test to work, but it’s not working. I think it has something to do with the reverse function, which I think needs an array, but it’s not doing anything right now. I probably have a ton of mistakes here, I apologize! I’m just trying to get it to even check if “A” is a palindrome and say it’s a palindrome.

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="styles.css">
    <title>Palindrome Checker</title>
    <input id="text-input">
    <button id="check-btn"></button>
    <div id="result"></div>
    <script src="script.js"></script>
/* file: styles.css */

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

function checkPalindrome() {
  const userInput = [textInput.innerText.replace(/[^a-zA-Z0-9]/g, '').toLowerCase()];
  let resultMsg = result.innerText;

if (userInput === userInput.reverse().join("")) {
  resultMsg === userInput + " is a palindrome";

checkButton.addEventListener("click", checkPalindrome);

/*if (userInput === "") {
  alert("Please input a value");

Your browser information:

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

Challenge Information:

Build a Palindrome Checker Project - Build a Palindrome Checker

Welcome to the forum @JPlumb

Try adding an alert with the string "test'’ as the first line in the function.

Then press the button.

See what happens.

Happy coding

double check your operators, do you want a comparison here?