-
Notifications
You must be signed in to change notification settings - Fork 10
/
38_valid_email.js
37 lines (27 loc) · 996 Bytes
/
38_valid_email.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
Valid email
Don't use any solutions you find on the web, try building
this from scrath by yourself!
validEmail takes one argument 'email'. Return true if
the email is a valid email. Otherwise, return false.
Email validation can gety really complicated,
this challenge will satisfy 95% of use cases.
Rules:
- The string must contain an "@" character.
- The string must contain a "." character.
- The "@" character must have a minimum of one character in front of it.
- The " . " and the "@" must be in the appropriate places.
(john.doe@com is invalid, [email protected] is valid.)
Examples:
validEmail('@gmail.com') ➞ false
validEmail('hello.gmail@com') ➞ false
validEmail('gmail') ➞ false
validEmail('hello@gmail') ➞ false
validEmail('[email protected]') ➞ true
validEmail('') ➞ false
Use the tests to guide you toward a solution:
mocha tests/38_valid_email_test.js
*/
const validEmail = (email) => {
}
module.exports = validEmail