Learn Regular Expressions by Building a Spam Filter - Step 23

Tell us what’s happening:

Describe your issue in detail here.

Your code so far

kinda stuck

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

const helpRegex = /please help|assist me/i;
const dollarRegex = /[0-9]+ (?:hundred|thousand|million|billion)? dollars/i;

// User Editable Region

const freeRegex = /[fr][e3] mon[e3]y/i;

// User Editable Region


const denyList = [helpRegex, dollarRegex, freeRegex];

const isSpam = (msg) => denyList.some((regex) => regex.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/122.0.0.0 Safari/537.36

Challenge Information:

Learn Regular Expressions by Building a Spam Filter - Step 23

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.

this will not match free anymore! a character class will match only one character

You did good with the e in money

you need to do the same thing with the two letters e in free

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