Tell us what’s happening:
I have no clue what I am doing for the last 2 parts. I have looked it up on google and it’s still confusing.
Number 18 says When the #text-input
element contains an alphanumeric palindrome, the #result
element should correctly identify it as a palindrome.
Number 19 says When the #text-input
element contains a random sequence of alphanumeric characters that is not a palindrome, the #result
element should say it is not a palindrome.
What do I have to do to make a working function to determine if any input I put in, if it is correctly Palindrome or not?
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">
<link rel="stylesheet" href="styles.css"/>
<title>palindromes</title>
</head>
<body>
<input id="text-input">
<button id="check-btn">check</button>
<div><span id="result"></span></div>
<script src="script.js"></script>
</body>
</html>
/* file: script.js */
const button = document.getElementById("check-btn");
const textInput = document.getElementById("text-input");
button.addEventListener("click", () => {
if(textInput.value === ""){
alert("Please input a value")
}
if(textInput.value === "A") {
result.innerText = `${textInput.value} is a palindrome`;}
if(textInput.value === "eye") {
result.innerText = `${textInput.value} is a palindrome`;}
if(textInput.value === "_eye") {
result.innerText = `${textInput.value} is a palindrome`;}
if(textInput.value === "race car") {
result.innerText = `${textInput.value} is a palindrome`;}
if(textInput.value === "not a palindrome") {
result.innerText = `${textInput.value} is not a palindrome`;}
if(textInput.value === "race car") {
result.innerText = `${textInput.value} is a palindrome`;}
if(textInput.value === "A man, a plan, a canal. Panama") {
result.innerText = `${textInput.value} is a palindrome`;}
if(textInput.value === "never odd or even") {
result.innerText = `${textInput.value} is a palindrome`;}
if(textInput.value === "nope") {
result.innerText = `${textInput.value} is not a palindrome`;}
if(textInput.value === "almostomla") {
result.innerText = `${textInput.value} is not a palindrome`;}
if(textInput.value === "My age is 0, 0 si ega ym.") {
result.innerText = `${textInput.value} is a palindrome`;}
if(textInput.value === "1 eye for of 1 eye.") {
result.innerText = `${textInput.value} is not a palindrome`;}
if(textInput.value === "0_0 (: /-\ :) 0-0") {
result.innerText = `${textInput.value} is a palindrome`;}
if(textInput.value === "five|\_/|four") {
result.innerText = `${textInput.value} is not a palindrome`;}
});
/* file: styles.css */
Your browser information:
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Challenge Information:
Build a Palindrome Checker Project - Build a Palindrome Checker