Skip to content

HW#6_Trupkina#22

Open
SvetlanaTr wants to merge 5 commits intomasterfrom
HW#6_Trupkina
Open

HW#6_Trupkina#22
SvetlanaTr wants to merge 5 commits intomasterfrom
HW#6_Trupkina

Conversation

@SvetlanaTr
Copy link
Copy Markdown
Collaborator

No description provided.

Comment on lines +6 to +7
if (email === null) return undefined;//i catch cancellation
else if (regexp_email.test(email) === true) return alert('This is your Email:\n' + email);
Copy link
Copy Markdown
Owner

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 (...) { ... }


function validEmail() {
//Set the default value
let email = prompt('Type correctly email please', `example@gmail.com`);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better write pure function

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();
Copy link
Copy Markdown
Owner

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?

Comment on lines +5 to +7
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);
Copy link
Copy Markdown
Owner

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

Comment on lines +12 to +17
//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();
Copy link
Copy Markdown
Owner

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be done!

'exa23@44m.p-le@Flora-mix.ru' //false - for all ()!@#$%^&*=
];
console.log(validEmail(email));
function validEmail(mail) {
Copy link
Copy Markdown
Owner

@DmitryKorolDevPro DmitryKorolDevPro Mar 24, 2021

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

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
Copy link
Copy Markdown
Owner

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

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) {
Copy link
Copy Markdown
Owner

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))

'############' //false
];
console.log(validPassword(password));
function validPassword(pass) {
Copy link
Copy Markdown
Owner

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.

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) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary checking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants