Conversation
| transformNumber(phone) { | ||
| if(this.checkForNumbers(phone)){ | ||
| let arrPhone = phone.split(''); | ||
| arrPhone.splice(0, 0, '('); |
There was a problem hiding this comment.
lets think can we apply regexp here, it would simplify that construction a lot
| ] | ||
| }; | ||
|
|
||
| checkForNumbers(phone) { |
There was a problem hiding this comment.
probably in most cases there should be better name similar to
isPhoneNumberValid
meaning of "is" prefix at the beginning that function return boolean
| let validNumber = numberArrPhone.some((elem) => { | ||
| return isNaN(elem) | ||
| }); | ||
| if(validNumber) { |
There was a problem hiding this comment.
I guess we can just write that way
return validNumber| }; | ||
|
|
||
| changeUserData(initialUser, value) { | ||
| let arr = this.dataBase; |
There was a problem hiding this comment.
it's hard to understand what does that function doing
| phoneApp.addUser(3, 'Natalia', '0995305300'); | ||
| phoneApp.removeUserByName('Tom2'); | ||
| phoneApp.searchByName('Natalia'); | ||
| phoneApp.changeUserData(3, 5); |
There was a problem hiding this comment.
not sure it easy to understand what 3 and 5 refers to.
I guess the public API(interface) should looks similar to that one
changeUser(userIdToChange, updatedUser) {
}and inside of that method, you looking for the user with unique ID and than update it
| let phoneApp = new PhoneApp(); | ||
| console.log('проверенный и преобразованый номер --->', phoneApp.transformNumber('0995305385')); | ||
| console.log('номер не прошедший проверку --->', phoneApp.transformNumber('099530)5385')); | ||
| phoneApp.addUser(3, 'Natalia', '0995305300'); |
There was a problem hiding this comment.
I guess it's better to pass directly object with properties it would "self-documented-code"
| }; | ||
|
|
||
| addUser(id, name, phone) { | ||
| let objUser = { |
There was a problem hiding this comment.
You can create an additional class which would create such a user.
And if we go further maybe even phone-number validation should be made inside of User class.
Not sure if it the responsibility of phone-book to validate users.
The main responsibility of phone-book is to find users, update them and delete them
No description provided.