Conversation
|
🍅 Пройдено тестов 16 из 26 |
|
🍅 Не пройден линтинг или базовые тесты |
|
🍅 Пройдено тестов 16 из 26 |
|
🍅 Пройдено тестов 16 из 26 |
|
🍅 Пройдено тестов 17 из 26 |
|
🍅 Пройдено тестов 17 из 26 |
|
🍅 Пройдено тестов 18 из 26 |
|
🍅 Пройдено тестов 18 из 26 |
|
🍅 Пройдено тестов 18 из 26 |
|
🍅 Пройдено тестов 22 из 26 |
|
🍅 Пройдено тестов 22 из 26 |
|
🍅 Пройдено тестов 22 из 26 |
|
🍅 Пройдено тестов 19 из 23 |
|
🍅 Пройдено тестов 22 из 26 |
|
🍅 Пройдено тестов 22 из 26 |
|
🍅 Пройдено тестов 22 из 26 |
|
🍅 Пройдено тестов 22 из 26 |
|
🍅 Пройдено тестов 22 из 26 |
|
🍅 Пройдено тестов 22 из 26 |
|
🍏 Пройдено тестов 26 из 26 |
|
@plotnikovn обрати внимание: решено доп. задание |
|
|
||
| function check(phone, name) { | ||
| if (typeof phone !== 'string' || typeof name !== 'string' || name.length <= 0 || | ||
| phone <= 0) { |
There was a problem hiding this comment.
– длина строки не может быть отрицательной
– phone <= 0 не лучшая идея сравнивать на строку с числом
| return false; | ||
| } | ||
|
|
||
| return /^\d{10}$/.test(phone); |
There was a problem hiding this comment.
длину телефона можно не проверять, т.к. в регулярном выражении ты задаешь фиксированное количество символов
| return /^\d{10}$/.test(phone); | ||
| } | ||
|
|
||
| function check2(email) { |
There was a problem hiding this comment.
давай осмысленные названия функциям
| return false; | ||
| } | ||
| } | ||
| if (email === undefined) { |
There was a problem hiding this comment.
тут лучше поменять местами, и тогда проверка станет проще
if (email === undefined) {
return true;
}
return typeof email === 'string' && email.length;| } | ||
|
|
||
| function generalCheck(phone, name, email) { | ||
| if (check(phone, name) === false || check2(email) === false) { |
There was a problem hiding this comment.
можно сразу сделать return
return check(…) || check2(…);| * @returns {Boolean} | ||
| */ | ||
| function add(phone, name, email) { | ||
| if (generalCheck(phone, name, email) === false) { |
| if (generalCheck(phone, name, email) === false) { | ||
| return false; | ||
| } | ||
| if (checkPhone(phone) === true) { |
| if (generalCheck(phone, name, email) === false) { | ||
| return false; | ||
| } | ||
| phoneBook.forEach(element => { |
There was a problem hiding this comment.
здесь лучше подойдет .some
https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Array/some
| if (element.phone.includes(query) === true || | ||
| element.name.includes(query) === true || | ||
| (element.email ? element.email.includes(query) : false)) { | ||
| string = element.name + ', +7 (' + element.phone.slice(0, 3) + ') ' + |
There was a problem hiding this comment.
лучше сделать отдельную функцию для форматирования записи
No description provided.