This is the email validation coding.
I only know to do example 5, the email length must over 5 strings, otherwise, it will become error and remind people to re-write the email.
I don’t know how to write the example 2-4 based on the email requirements. Kindly please give me some advices. Thank you so much!
function validateEmail(email) {
console.log(email)
// email requirements as below:
// email length >= 5 character
// @ cannot be the first character
// @ must before .
// . cannot be the last character
// example
// 1. a@a.com < return true
// 2. @a.com < return false, throw TypeError: invalid email address
// 3. a.b@com < return false, throw TypeError: invalid email address
// 4. a@a.com. < return false, throw TypeError: invalid email address
// 5. a@a.c < return false, throw TypeError: e-mail address too short
// 6. a@.com < return ture
// example 5, email length >= 5 character
if(email.length<5) {
throw new TypeError(`e-mail address too short`)
}
// example 4, . cannot be the last character
}
// example 1,6
return true
function newFunction() {
return "'"
}