Skip to content

Conversation

@PAVLUXAN
Copy link
Contributor

@PAVLUXAN PAVLUXAN commented Jun 9, 2025

@keksobot keksobot changed the title feat:create Function GeneratePhoto Больше деталей Jun 9, 2025
@keksobot
Copy link
Contributor

keksobot commented Jun 9, 2025

♻️ Я собрал ваш пулреквест. Посмотреть можно здесь.

keksobot pushed a commit that referenced this pull request Jun 9, 2025
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)];

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,

Choose a reason for hiding this comment

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

В таком варианте id комментариев будут повторяться для каждой фотографии. По ТЗ: У каждого комментария есть идентификатор — id — любое число. Идентификаторы не должны повторяться

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`,

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),

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 = ['Всё отлично!', 'В целом всё неплохо. Но не всё.', 'Когда вы делаете фотографию, хорошо бы убирать палец из кадра. В конце концов это просто непрофессионально.',

Choose a reason for hiding this comment

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

коллекции - существительное во множественом числе

return Desc;
};

const getPhotoDesc = () =>{

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 = () => {

Choose a reason for hiding this comment

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

название не соответствует решению - если используется только коллекция сообщений, лучше связать название с сообщениями.

Идеальное решение: отдельная функция перемешивания массива. После вызова перемешивания берем нужные элементы из перемешанной коллекции.

@keksobot keksobot merged commit eb4ef85 into htmlacademy-javascript:master Jun 13, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants