Build a Palindrome Checker Project - Build a Palindrome Checker

Tell us what’s happening:

Describe your issue in detail here.
When the #text-input element only contains the letter A and the #check-btn element is clicked, the #result element should contain the text A is a palindrome .
i am getting problem in this step

<!-- file: index.html -->
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Palindrome Checker</title>
  <link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
  <h1>Palindrome Checker</h1>
  <label for="text-input">Enter a word or phrase:</label>
  <input type="text" id="text-input" required>
  <button type="submit" id="check-btn" onclick="myFunction()">Check</button>
  <div id="result"></div>
  
  <script src="script.js"></script>
  <script src="https://replit.com/public/js/replit-badge-v2.js" theme="dark" position="bottom-right"></script>
</body>

</html>
/* file: styles.css */

/* file: script.js */


function myFunction(){
  let textinput = document.getElementById('text-input').value;
const checkbtn = document.getElementById('check-btn').innerHTML;
let result = document.getElementById('result');
  if(textinput == ""){
      alert("Please input a value");
    }
  else if(textinput == "A" && document.getElementById('check-btn').clicked == true){
        console.log("A is a palindrome");
  }
}

Your browser information:

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

Challenge Information:

Build a Palindrome Checker Project - Build a Palindrome Checker

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

Hi @divya.singh1984

The .click method is used to simulate a mouse click, and returns undefined, so may not be appropriate to use in this instance.

You will also want the result to display in the browser.

Happy coding

you need to change this element when the button is clicked

to know when the button is clicked, remember there is onclick, buttons do not have a clicked property

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