Learn Regular Expressions by Building a Spam Filter - Step 3

Alert doesn’t pass.

Instructions:

Step 3

If the messageInput is empty, display an alert to the user with the message Please enter a message..

Then, exit the function execution.

My code:

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

Error message:

Sorry, your code does not pass. Try again.

Your if statement should display an alert to the user with the message Please enter a message..

do not use return maybe?

That doesn’t solve the problem, I have already tried it and here is the error message I got:

Sorry, your code does not pass. Keep trying.

Your if statement should exit the function execution.

can you provide the link to the step?

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-regular-expressions-by-building-a-spam-filter/step-3

If the messageInput is empty, display an alert to the user with the message Please enter a message..

You first write the alert, then after the alert…

Then, exit the function execution.

after the alert you write the return

1 Like

Thanks a lot ilenia!

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