I'm writing a JS function that prompts the user to enter an email address. I want to confirm that the user input is an email address by checking if an '@' sign exists within the input. Then I want to return the email address if it's true.
My python knowledge has me writing this line, "if at == true return email", but the console is returning a syntax error. Any ideas? Code below:
function email_of_user() {
var email = prompt("What is your email?");
var at = email.indexOf("@");
if at === true return email
}
PS. This is code is within an HTML doc, rather than a standalone JS file.