-
Notifications
You must be signed in to change notification settings - Fork 1
Больше деталей #4
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
Больше деталей #4
Conversation
|
♻️ Я собрал ваш пулреквест. Посмотреть можно здесь. |
js/main.js
Outdated
| const result = Math.random() * (upper - lower + 1) + lower; | ||
| return Math.floor(result); | ||
| }; | ||
| const getRandomArrayElement = (elements) => elements [getRandomPositiveInteger(0, elements.length - 1)]; |
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.
Функции полезно отделять одной пустой строкой, до и после
js/main.js
Outdated
| const comments = []; | ||
| for (let i = 0; i < limit; i += 1) { | ||
| const comment = { | ||
| commentId : i, |
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.
В таком варианте id комментариев будут повторяться для каждой фотографии. По ТЗ: У каждого комментария есть идентификатор — id — любое число. Идентификаторы не должны повторяться
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.
Поле id называется
js/main.js
Outdated
| for (let i = 0; i < limit; i += 1) { | ||
| const comment = { | ||
| commentId : i, | ||
| commentAvatar : `img/avatar-${getRandomPositiveInteger(1, 6)}.svg`, |
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.
avatar, message - слово comment не должно дублироваться в именах свойств
js/main.js
Outdated
| const comment = { | ||
| commentId : i, | ||
| commentAvatar : `img/avatar-${getRandomPositiveInteger(1, 6)}.svg`, | ||
| commentMessage : getRandomArrayElement(message), |
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.
Как реализовано получение двух предложений?
Для формирования текста комментария — message — вам необходимо взять одно или два случайных предложения...
js/main.js
Outdated
| @@ -1,0 +1,50 @@ | |||
| const description = [ 'Я в кафе', 'ловлю мышь', 'Залез на холодильник', 'Катаю шарик', 'Сплю под одеялом']; | |||
| const message = ['Всё отлично!', 'В целом всё неплохо. Но не всё.', 'Когда вы делаете фотографию, хорошо бы убирать палец из кадра. В конце концов это просто непрофессионально.', | |||
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.
коллекции - существительное во множественом числе
| return Desc; | ||
| }; | ||
|
|
||
| const getPhotoDesc = () =>{ |
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.
Сокращать слова в названиях не полезно - из текущего названия не очевидно, что вернется множество
getPhotoDescriptions
так как функция одиночного описания тоже связана с фото - надо упомянуть об этом
getPhotoDescription
либо не упоминать в обоих
|
|
||
| const getRandomItem = (items) => items [getRandomNumber(0, items.length - 1)]; | ||
|
|
||
| const getUniqueItem = () => { |
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.
название не соответствует решению - если используется только коллекция сообщений, лучше связать название с сообщениями.
Идеальное решение: отдельная функция перемешивания массива. После вызова перемешивания берем нужные элементы из перемешанной коллекции.
🎓 Больше деталей
💥 https://htmlacademy-javascript.github.io/2607777-kekstagram-2/4/