Build a Spam Filter - Step 9

Tell us what’s happening:

what is wrong here please i need help i dont know why i not passing the test

Your code so far

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


// User Editable Region

const helpRegex = /please help | assist me/i;

// User Editable Region


const isSpam = (msg) => helpRegex.test(msg);

checkMessageButton.addEventListener("click", () => {
  if (messageInput.value === "") {
    alert("Please enter a message.");
    return;
  }

  result.textContent = isSpam(messageInput.value)
    ? "Oh no! This looks like a spam message."
    : "This message does not seem to contain any spam.";
  messageInput.value = "";
});

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36

Challenge Information:

Build a Spam Filter - Step 9
https://www.freecodecamp.org/learn/full-stack-developer/workshop-spam-filter/step-9

please i need help

Hi. Look closely at the syntax in the example code for an alternate sequence against your code:

/yes|no/ 

thanks seen the problem really appreciate.

1 Like