Skip to content
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

Лопатин Николай #93

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

LopatinNikolai
Copy link

No description provided.

@honest-hrundel honest-hrundel changed the title javascript-task-2 Лопатин Николай Oct 25, 2018
@honest-hrundel
Copy link

🍅 Пройдено тестов 16 из 26

@honest-hrundel
Copy link

🍅 Не пройден линтинг или базовые тесты

@honest-hrundel
Copy link

🍅 Пройдено тестов 16 из 26

@honest-hrundel
Copy link

🍅 Пройдено тестов 16 из 26

@honest-hrundel
Copy link

🍅 Пройдено тестов 17 из 26

@honest-hrundel
Copy link

🍅 Пройдено тестов 17 из 26

@honest-hrundel
Copy link

🍅 Пройдено тестов 18 из 26

@honest-hrundel
Copy link

🍅 Пройдено тестов 18 из 26

@honest-hrundel
Copy link

🍅 Пройдено тестов 18 из 26

@honest-hrundel
Copy link

🍅 Пройдено тестов 22 из 26

@honest-hrundel
Copy link

🍅 Пройдено тестов 22 из 26

@honest-hrundel
Copy link

🍅 Пройдено тестов 22 из 26

@honest-hrundel
Copy link

🍅 Пройдено тестов 19 из 23

@honest-hrundel
Copy link

🍅 Пройдено тестов 22 из 26

@honest-hrundel
Copy link

🍅 Пройдено тестов 22 из 26

@honest-hrundel
Copy link

🍅 Пройдено тестов 22 из 26

@honest-hrundel
Copy link

🍅 Пройдено тестов 22 из 26

@honest-hrundel
Copy link

🍅 Пройдено тестов 22 из 26

@honest-hrundel
Copy link

🍅 Пройдено тестов 22 из 26

@honest-hrundel
Copy link

🍏 Пройдено тестов 26 из 26

@honest-hrundel
Copy link

@plotnikovn обрати внимание: решено доп. задание


function check(phone, name) {
if (typeof phone !== 'string' || typeof name !== 'string' || name.length <= 0 ||
phone <= 0) {

Choose a reason for hiding this comment

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

– длина строки не может быть отрицательной
phone <= 0 не лучшая идея сравнивать на строку с числом

return false;
}

return /^\d{10}$/.test(phone);

Choose a reason for hiding this comment

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

длину телефона можно не проверять, т.к. в регулярном выражении ты задаешь фиксированное количество символов

return /^\d{10}$/.test(phone);
}

function check2(email) {

Choose a reason for hiding this comment

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

давай осмысленные названия функциям

return false;
}
}
if (email === undefined) {

Choose a reason for hiding this comment

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

тут лучше поменять местами, и тогда проверка станет проще

if (email === undefined) {
  return true;
}

return typeof email === 'string' && email.length;

}

function generalCheck(phone, name, email) {
if (check(phone, name) === false || check2(email) === false) {

Choose a reason for hiding this comment

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

можно сразу сделать return

return check() || check2();

@@ -19,7 +54,17 @@ let phoneBook;
* @returns {Boolean}
*/
function add(phone, name, email) {
if (generalCheck(phone, name, email) === false) {

Choose a reason for hiding this comment

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

if (!generalCheck()) {

}

if (generalCheck(phone, name, email) === false) {
return false;
}
if (checkPhone(phone) === true) {

Choose a reason for hiding this comment

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

аналогично

if (generalCheck(phone, name, email) === false) {
return false;
}
phoneBook.forEach(element => {

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

лучше сделать отдельную функцию для форматирования записи

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

Successfully merging this pull request may close these issues.

3 participants