I got a problem and dont undestand the error it throws,
You should use ternary syntax to check the truthiness of isSpam(messageInput.value)
This is question
After the if
statement, use a ternary operator to check the truthiness of calling isSpam()
with messageInput.value
as the argument. If true, set the textContent
property on the result
element to "Oh no! This looks like a spam message."
. Otherwise, set it to "This message does not seem to contain any spam."
Then set the messageInput
element’s value
property to an empty string.
const messageInput = document.getElementById("message-input");
const result = document.getElementById("result");
const checkMessageButton = document.getElementById("check-message-btn");
const isSpam = (msg) => false;
checkMessageButton.addEventListener("click", () => {
if (messageInput.value === "") {
alert("Please enter a message.");
return;
}
result.textContent = isSpam(messsageInput.value) ? "Oh no! This looks like a spam message." : "This message does not seem to contain any spam.";
messsageInput.value = "";
});
How do I fix this?