-
Notifications
You must be signed in to change notification settings - Fork 0
HW#6_Trupkina #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
HW#6_Trupkina #22
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same as the previous function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be done!
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary checking
No description provided.