Skip to content

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

Open
LopatinNikolai wants to merge 20 commits into
urfu-2018:masterfrom
LopatinNikolai:master
Open

Лопатин Николай#93
LopatinNikolai wants to merge 20 commits into
urfu-2018:masterfrom
LopatinNikolai:master

Conversation

@LopatinNikolai
Copy link
Copy Markdown

No description provided.

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

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

@honest-hrundel
Copy link
Copy Markdown

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

Comment thread phone-book.js

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

Choose a reason for hiding this comment

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

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

Comment thread phone-book.js
return false;
}

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

Choose a reason for hiding this comment

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

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

Comment thread phone-book.js
return /^\d{10}$/.test(phone);
}

function check2(email) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread phone-book.js
return false;
}
}
if (email === undefined) {
Copy link
Copy Markdown

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;

Comment thread phone-book.js
}

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

Choose a reason for hiding this comment

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

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

return check() || check2();

Comment thread phone-book.js
* @returns {Boolean}
*/
function add(phone, name, email) {
if (generalCheck(phone, name, email) === false) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if (!generalCheck()) {

}

Comment thread phone-book.js
if (generalCheck(phone, name, email) === false) {
return false;
}
if (checkPhone(phone) === true) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

аналогично

Comment thread phone-book.js
if (generalCheck(phone, name, email) === false) {
return false;
}
phoneBook.forEach(element => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread phone-book.js
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) + ') ' +
Copy link
Copy Markdown

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