Preview:
const emailIsValid = (email) => {
  if (!(typeof email === "string" || email instanceof String)) {
    console.error(`string expected, ${typeof email} provided`)
    return false
  }
  const expression = /\S+@\S+\.\S+/
  return expression.test(email)
}

emailIsValid("somebody@somewhere.com") // true
emailIsValid("nobody@nowhere") // false
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter