-
Notifications
You must be signed in to change notification settings - Fork 99
ДЗ_1 Java #3
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: master
Are you sure you want to change the base?
ДЗ_1 Java #3
Conversation
| { title: 'Gamepad', id: 4, price: 87 }, | ||
| { title: 'Новый Товар', id: 5 } | ||
| ]; | ||
| const renderProduct = (title, id, price = 'Цена товара', img = "https://placehold.it//150x100") => { |
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.
У вас опечатка в урле изображения, лишний слэш после .it - https://placehold.it/150x100 должно быть так.
Не согласен с аргументом по умолчанию для цены - у вас строка в качестве дефолтного значения price сейчас. А какой тип у этого аргумента мы ждем? Мы ждем число, и вот тут очень неявная история получается, во-первых читая код непонятно, что в итоге то будет попадать в price, судя по тому, что есть сейчас строка, а если смотреть уже на данные товаров - число. Во-вторых это может привести к проблемам в коде - допустим использовались бы какие-то явно зависимые от числовых значений методы, а по дефолту мы бы вдруг строку обрабатывали. В общем куда правильнее задавать дефолтные значения того же типа, который мы ожидаем получать реально.
| }; | ||
|
|
||
| const render = (products) => { | ||
| document.querySelector('.products').innerHTML = products.map(item => renderProduct(item.title, item.id, item.price)).join(''); |
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.
По 3-му заданию все выполнено верно
| } | ||
| button{ | ||
| margin: 5px; | ||
| } No newline at end of file |
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.
Принимаю стили
ДЗ_1 Java