Conversation
HW6(Async-RegExp)/HW6_Trupkina.js
Outdated
| if (email === null) return undefined;//i catch cancellation | ||
| else if (regexp_email.test(email) === true) return alert('This is your Email:\n' + email); |
There was a problem hiding this comment.
pls, try do not use syntax like that
for readable better write
if (...) { ... } else if (...) { ... }
HW6(Async-RegExp)/HW6_Trupkina.js
Outdated
|
|
||
| function validEmail() { | ||
| //Set the default value | ||
| let email = prompt('Type correctly email please', `example@gmail.com`); |
There was a problem hiding this comment.
better write pure function
HW6(Async-RegExp)/HW6_Trupkina.js
Outdated
| const regexp_email = /^([\w\.+-]{3,})+@[A-z0-9-]{3,10}\.[A-z]{2,6}$/;//we can't use \w in domen name and sub name | ||
| if (email === null) return undefined;//i catch cancellation | ||
| else if (regexp_email.test(email) === true) return alert('This is your Email:\n' + email); | ||
| return validEmail(); |
There was a problem hiding this comment.
Why do you need the function to return itself?
HW6(Async-RegExp)/HW6_Trupkina.js
Outdated
| const regexp_email = /^([\w\.+-]{3,})+@[A-z0-9-]{3,10}\.[A-z]{2,6}$/;//we can't use \w in domen name and sub name | ||
| if (email === null) return undefined;//i catch cancellation | ||
| else if (regexp_email.test(email) === true) return alert('This is your Email:\n' + email); |
There was a problem hiding this comment.
I do not understand the logic of this function, let's discuss it by voice
HW6(Async-RegExp)/HW6_Trupkina.js
Outdated
| //Set the default value with Math.random() if user doesn't want to come up with password | ||
| let password = prompt('Type your password please', Math.floor(Math.random() * Math.floor(999999)) + 'Add!t'); | ||
| const regexp_pass = /^.*(?=.{8,})(?=.+[A-Z])(?=.+[a-z])(?=.*[!@#$%^&*?+=-]).*$/; | ||
| if (password === null) return undefined;//i catch cancellation | ||
| else if (regexp_pass.test(password) === true) return alert('This is your password:\n' + password); | ||
| return validPassword(); |
There was a problem hiding this comment.
the same as the previous function
HW6(Async-RegExp)/HW6_Trupkina.js
Outdated
| 'exa23@44m.p-le@Flora-mix.ru' //false - for all ()!@#$%^&*= | ||
| ]; | ||
| console.log(validEmail(email)); | ||
| function validEmail(mail) { |
There was a problem hiding this comment.
function name should be a verb.
and this still not reading the function
HW6(Async-RegExp)/HW6_Trupkina.js
Outdated
| function validEmail(mail) { | ||
| const regexp_email = /^([\w\.+-]{3,})+@[A-z0-9-]{3,10}\.[A-z]{2,6}$/;//we can't use \w in domen name and sub name because '_' included | ||
| for (const iterator of mail) { | ||
| //console.log(`${iterator}: ${regexp_email.test(iterator) === true}`);//can be write shorter |
There was a problem hiding this comment.
don't leave dead code in PR
HW6(Async-RegExp)/HW6_Trupkina.js
Outdated
| const regexp_email = /^([\w\.+-]{3,})+@[A-z0-9-]{3,10}\.[A-z]{2,6}$/;//we can't use \w in domen name and sub name because '_' included | ||
| for (const iterator of mail) { | ||
| //console.log(`${iterator}: ${regexp_email.test(iterator) === true}`);//can be write shorter | ||
| if (regexp_email.test(iterator) === true) { |
There was a problem hiding this comment.
unnecessary checking. you can just leave
if (regexp_email.test(iterator))
HW6(Async-RegExp)/HW6_Trupkina.js
Outdated
| '############' //false | ||
| ]; | ||
| console.log(validPassword(password)); | ||
| function validPassword(pass) { |
There was a problem hiding this comment.
function name should be a verb.
HW6(Async-RegExp)/HW6_Trupkina.js
Outdated
| Large and small letters must be present, the password is at least 8 characters long */ | ||
| const regexp_pass = /^.*(?=.{8,})(?=.+[A-Z])(?=.+[a-z])(?=.*[!@#$%^&*?+=-]).*$/; | ||
| for (const iterator of pass) { | ||
| if (regexp_pass.test(iterator) === true) { |
No description provided.