Tell us what’s happening:
I’m working on an alert. The code doesn’t pass. Even though on Codepen everything’s working. But on freecodecamp i don’t even get the alert.
Your code so far
<!-- file: index.html -->
<! DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charset="UTF-8" />
<title>Palindrome Checker</title>
<link href="styles.css" rel="stylesheet" />
</head>
<body>
<h1>Palindrome Checker</h1>
<h2>Welcome to my Palindrome Checker</h2>
<p>Here you can check your text for palindromness. Just input it in a window below to get the text checked.</p>
<input for="text" id="text-input" />
<div id="result"></div>
<button id="check-btn" type="button">Check</button>
<script>
</script>
</body>
</html>
/* file: styles.css */
body {
min-height: 100vh;
}
*, ::before, ::after {
box-sizing: border-box;
}
#text-input {
display: block;
margin: auto;
background-color: red;
width: 300px;
height: 100px;
overflow: auto;
border-top: solid black;
}
#result {
display: block;
margin: auto;
background-color: red;
width: 300px;
height: 40px;
overflow: auto;
border-bottom: solid black;
}
#check-btn {
position: absolute;
right: 250px;
bottom: 100px;
}
h1, h2, p {
text-align: center;
}
/* file: script.js */
const checkButton = document.getElementById("check-btn");
const result = document.getElementById("result");
function check() {
let input = document.getElementById("text-input").value;
if (!input) {
var alert = "Please input a value";
alert();
}
}
checkButton.addEventListener("click", check);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Challenge Information:
Build a Palindrome Checker Project - Build a Palindrome Checker