<!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>FCC Palindrome Checker</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1> Pal Check #2</h1>
<p>A palindrome is a word or phrase that can be read the same way forwards and backwards, ignoring punctuation, case, and spacing.
<p>
<div id="fillIn">
<input id="text-input" type="text" placeholder="Please input a value." </input>
<button id="check-btn" onclick="checkPalindrome()">Click</button>
<!--value-->
<div id="result">
</div>
</div>
<script src="index.js"></script>
</body>
</html>
const input = document.getElementById("text-input");
const button = document.getElementById("check-btn");
const result = document.getElementById("result");
function checkPalindrome() {
const valueWord = input.value;
const regEx = /[^A-Za-z0–9]/gi;
const newWord = valueWord.toLowerCase().replace(regEx, "");
const reverseWord = newWord.split("").reverse().join("");
if (("onclick", input.value === "")) {
alert("Please input a value");
} else if (("onclick", newWord === reverseWord)) {
resultWord = input.value + " is a palindrome";
} else {
resultWord = input.value + " is a not palindrome";
}
result.innerHTML = resultWord;
}
button.addEventListener("onclick", checkPalindrome());
The “alert”, css, and the palindrome work in other editors….like codepen. It does not work in free code camp.
I have tried: clearing my browser history. I have made sure that fcc has permission to open alerts and pop-ups.
I understand that this is not an elegant solution, but it does work elsewhere. I don’t know how to fix this.