Learn Regular Expressions by Building a Spam Filter - Step 5

Tell us what’s happening:

Describe your issue in detail here.
confused ive with just = and += and it wont pass

Your code so far

/* file: script.js */
const messageInput = document.getElementById("message-input");
const result = document.getElementById("result");
const checkMessageButton = document.getElementById("check-message-btn");

const isSpam = (msg) => false;


// User Editable Region

checkMessageButton.addEventListener("click", () => {
  if (messageInput.value === "") {
    alert("Please enter a message.");
    return;
  }
 return isSpam(messageInput.value)? result.textContent += 'Oh no! This looks like a spam message.': result.textContent = 'This message does not seem to contain any spam.';

});

// User Editable Region

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:

Learn Regular Expressions by Building a Spam Filter - Step 5

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

Hi @GavinEscanilla

You should use the assignment operator to set the textContent property of the result element.

Looks like you need to assign the expression to the outcome of the ternary operator.
Happy coding

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.