Tell us what’s happening:
I’ve been editing and researching different ways to write the same code and I can’t figure out why it’s not passing. VS Code has no errors, I am S-T-U-C-K!!!
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Build a Palindrome Checker</title>
<link rel="stylesheet" href="./styles.css" />
</head>
<body>
<main class="container">
<h1>Palindrome Checker</h1>
<div class="palindrome-div">
<label for="text-input">Type palindrome here:</label>
<input
class="palindrome-input"
id="text-input"
value=""
type="text"
/>
<button class="palindrome-btn" id="check-btn">Check</button>
<div class ="palindrome-result" id="result"></div>
</div>
<div class="palindrome-definition-div">
<p class="palindrome-definition">A palindrome is a word or sentence that's spelled the same way forward and backward, without punctuation and ignoring the case and spacing.</p>
</div>
</main>
<script src=".script.js"></script>
</body>
</html>
/* file: styles.css */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: sans-serif;
background-color: #0a0a23;
color: #ffffff;
}
.container {
width: 100%;
min-height: 100vh;
position: relative;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.title {
text-align: center;
padding: 10px 0;
font-size: 2.5rem;
margin-bottom: 20px;
}
.palindrome-div {
width: min(100vw, 450px);
min-height: 100px;
border-radius: 20px;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
padding: 20px;
margin: 20px 0;
background-color: #ffffff;
box-shadow: 0 6px 6px #002ead;
}
label {
color: #0a0a23;
margin-bottom: 20px;
}
.palindrome-btn {
width: 90px;
border: none;
padding: 10px;
border-radius: 10px;
background-color: #ffd700;
color: #000000;
cursor: pointer;
}
.palindrome-input {
height: 30px;
width: 250px;
text-align: center;
font-size: 1.2rem;
margin: 10px;
border: none;
border-bottom: 2px solid #000000;
}
.palindrome-input:focus {
border-bottom: 3px solid #2f4f4f;
}
.palindrome-input::placeholder {
text-align: center;
}
.user-input {
font-size: 1.4rem;
margin-top: 10px;
text-align: center;
}
.results-div {
overflow-y: auto;
word-wrap: break-word;
min-height: 50px;
color: #000000;
}
.hidden {
display: none;
}
.palindrome-definition-div {
width: min(100vw, 450px);
font-size: 1.3rem;
min-height: 140px;
background-color: #1e90ff;
margin-top: 20px;
padding: 20px;
border-radius: 20px;
display: flex;
align-items: center;
justify-content: center;
}
.palindrome-definition {
vertical-align: middle;
text-align: center;
}
/* file: script.js */
const input = document.getElementById("text-input");
const check = document.getElementById("check-btn");
const divResult = document.getElementById("result");
const checkPalInput = input => {
if (checkPalInput === "") {
window.alert("Please input a value");
return;
} else {
const palLwr = checkPalInput.replace(/[^A-Za-z0-9]/g, "").toLowerCase();
let answerPal = `${checkPalInput} {
checkPalInput === [...palLwr].reverse().join("") ? " is" : " is not"
}
" a palindrome."`;
};
};
check.addEventListener("click", check);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0
Challenge Information:
Build a Palindrome Checker Project - Build a Palindrome Checker