What will be the output of the following JavaScript code? const email = "example@domain";
What will be the output of the following JavaScript code?
const email = "example@domain";
const regex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
console.log(regex.test(email));
Show answerHide answer
Correct answer: (C) FALSE
Explanation
The regex needs a dot and a 2-4 letter top-level domain after the @ part. "example@domain" has no ".com"-style ending, so test() returns false.