-
Notifications
You must be signed in to change notification settings - Fork 26
Lesson 6 #75
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: lesson-6
Are you sure you want to change the base?
Lesson 6 #75
Conversation
added homework for lesson 1
домашка lesson-1
домашка lesson-3
домашка lesson-3
домашка lesson-4
домашка lesson-6
} | ||
|
||
getCachedValue = (cachedValue, str) => { | ||
for(let key in cachedValue) { |
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.
let => const
|
||
function EmailValidator(str) { | ||
BaseValidator.call(this); | ||
|
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.
убери лишние пустые строки до и после объявления переменной
let result = getCachedValue(cachedValue, str); | ||
if(result === undefined) { //Валидировать дату через регулярное выражение, наверно, не самое правильное решение. Сильно длинно и нечитаемо... Но вариант через кучу if, пожалуй, не лучше... но если надо перепишу | ||
cachedValue[`${str}`] = /^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))([-.\/])(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/.test(str); | ||
return /^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))([-.\/])(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/.test(str) || false |
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.
вынеси регулярку в константу и юзай ее
let result = getCachedValue(cachedValue, str); | ||
if(result === undefined) { | ||
cachedValue[`${str}`] = /\([0-9]{3}\)\s[0-9]{3}-[0-9]{2}-[0-9]{2}/.test(str); | ||
return /\([0-9]{3}\)\s[0-9]{3}-[0-9]{2}-[0-9]{2}/.test(str) || false |
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.
тут также
можно все регекспы вынести в верх файла и юзать их по ходу дела
|
||
this.ucWords = (str) => { | ||
let myArray = str.split(' '); | ||
const n = myArray.length; |
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.
n переименуй
const n = myArray.length; | ||
|
||
for(let i = 0; i < n; i++) { | ||
myArray[i] = this.ucFirst(myArray[i]); |
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.
myArray тоже перименуй
return /^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+$/.test(str) || false | ||
} | ||
|
||
this.isDate = (str) => { //Валидировать дату через регулярное выражение, наверно, не самое правильное решение. Сильно длинно и нечитаемо... Но вариант через кучу if, пожалуй, не лучше... но если надо перепишу |
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.
комент пиши до функции
регулярку сделай так же, как в файле выше
@@ -0,0 +1,18 @@ | |||
function Worker(name1, surname1, rate1, days1) { | |||
this.name = name1; |
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.
name1 и тд переименуй
name1 => why not?
|
||
this.setRate = (rate2) => { | ||
rate = rate2; | ||
} |
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.
rate2 и подобное дальше переименуй
|
||
ucWords(str) { | ||
let myArray = str.split(' '); | ||
const n = myArray.length; |
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.
n, myArray, str переименуй
No description provided.