Build a Palindrome Checker Project - Build a Palindrome Checker

Tell us what’s happening:

I don’t know how to make the #return element display ‘A is not a palindrome’.
I think I have the right code, but I don’t know. Another thing, when I do Input a value, it still alerts: ‘Please input a value.’

Your code so far

<!-- file: index.html -->
<!DOCTYPE html> 
<html lang="en">   
<head>     
  <meta charset="UTF-8">     
  <meta name="viewport" content="width=device-width, initial-scale=1.0">     
  <meta http-equiv="X-UA-Compatible" content="ie=edge">     
  <title>Palindrome Checker</title>     
  <link rel="stylesheet" href="./styles.css">     
   </head>   
   <body>
     <input id="text-input"/>
     <button id="check-btn">Is it a palindrome?</button>
     <div id="result">

     </div>
  <script src="script.js"></script>   </body> 
  </html>
/* file: styles.css */

/* file: script.js */
const textInput = document.getElementById('text-input').value;
const button = document.getElementById('check-btn');
const results = document.getElementById('result');
let input = '';

// format stuff ig
function string(str){
  const alphabet = str.toLowerCase().match(/[a-z0-9]/g).join("");
  const clean = alphabeticArray.join("");
  const reverse = alphabeticArray.reverse().join('');

  //input value!!!1
  if (clean === reverse) {
    results.innerHTML = `${input} is a palindrome`;
  }else{
    results.innerHTML = `${input} is not a palindrome`
  }
};
//see if input = empty
function empty(){
  if (input === ''){
    alert("Please input a value");
    return;
  };
};

button.addEventListener('click', empty)

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36

Challenge Information:

Build a Palindrome Checker Project - Build a Palindrome Checker

  • how are you checking “user input”? here your “textInput” variable is not in use!!
  • “alphabeticArray” is also missing!!
  • “input” always contains an empty string!!

happy coding :slight_smile: