From ec5e4d5641f7327413cadb740f688210892e10d2 Mon Sep 17 00:00:00 2001 From: Alla Date: Thu, 18 Jun 2026 20:02:32 +0300 Subject: [PATCH 1/3] =?UTF-8?q?=D0=B3=D0=B5=D0=BD=D0=B5=D1=80=D0=B8=D1=80?= =?UTF-8?q?=D1=83=D0=B5=D1=82=20=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/function.js | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/js/function.js b/js/function.js index 56a3d0b..d7b60b0 100644 --- a/js/function.js +++ b/js/function.js @@ -1,29 +1,21 @@ - - //Функция для проверки длины строки +const checkString = (string, length) => string.length <= length; -let checksString = function (string, length) { - if (string.length <= length) { - return true; - } - return false; -}; //Функция для проверки, является ли строка палиндромом -let isPalindrome = function (string) { - let normalized = string +const isPalindrome = (string) => { + const normalized = string .replaceAll(' ', '') .toLowerCase(); let reversed = ''; for (let i = normalized.length - 1; i >= 0; i--) { - let char = normalized[i]; - reversed += char; + reversed += normalized[i]; } return normalized === reversed; }; //Функция извлечения цифр -let extractDigits = function (string) { +const extractDigits = (string) => { if (typeof string === 'number') { string = string.toString(); } @@ -34,12 +26,5 @@ let extractDigits = function (string) { digits += char; } } - if (digits === '') { - return NaN; - } - let result = parseInt(digits); - if (result < 0) { - result = result * -1; - } - return result; + return parseInt(digits, 10); }; From d2c3e0c8a400fd4c13af5a8f10ef513f0e936c66 Mon Sep 17 00:00:00 2001 From: Alla Date: Fri, 19 Jun 2026 21:00:18 +0300 Subject: [PATCH 2/3] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=204.16.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 63 ++++++++++++++++++++++++++++++++------------------ js/main.js | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 22 deletions(-) diff --git a/index.html b/index.html index 9fb6740..35e3f05 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,6 @@ + @@ -16,7 +17,8 @@

Фильтр фотографий

- +
@@ -46,7 +48,8 @@

Загрузка фотограф
- +
@@ -69,42 +72,48 @@

Загрузка фотограф
  • - +
  • - +
  • - +
  • - +
  • - +
  • - +

- - + + + + + diff --git a/js/main.js b/js/main.js index e69de29..b2f2558 100644 --- a/js/main.js +++ b/js/main.js @@ -0,0 +1,68 @@ +const NAMES = [ + 'Артём', + 'Борис', + 'Владимир', + 'Григорий', + 'Денис', + 'Анастасия', + 'Валерия', + 'Елена', + 'Ирина', + 'Ксения' +]; + +const DESCRIPTIONS = [ + 'Впечатления, которые остаются навсегда.', + 'Каждый кадр - часть летней истории.', + 'Простые вещи - самые важные.', + 'Отдых - это искусство жить.', + 'Вдохновение в каждом дне.', + 'Уют в простых вещах.', + 'Счастье в мелочах вокруг.', + 'Эмоции, которые остаются навсегда.', + 'Вкус к жизни в каждом дне.', + 'Любовь к жизни в деталях.' +]; + +const MESSAGES = [ + 'Всё отлично!В целом всё неплохо.Но не всё.', + 'Когда вы делаете фотографию, хорошо бы убирать палец из кадра.', + 'В конце концов это просто непрофессионально.', + 'Моя бабушка случайно чихнула с фотоаппаратом в руках и у неё получилась фотография лучше.', + 'Я поскользнулся на банановой кожуре и уронил фотоаппарат на кота и у меня получилась фотография лучше.', + 'Лица у людей на фотке перекошены, как будто их избивают.', + 'Как можно было поймать такой неудачный момент ?!' +] + +const SIMILAR_ARRAY_COUNT = 25; +const id = 25; +const likes = 200; +const comments = 30; +const avatar = 25; + +const getRandomInteger = (a, b) => { + const lower = Math.ceil(Math.min(a, b)); + const upper = Math.floor(Math.max(a, b)); + const result = Math.random() * (upper - lower + 1) + lower; + return Math.floor(result); +}; + +const getRandomArrayElement = (elements) => + elements[getRandomInteger(0, elements.length - 1)]; + +const createArray = () => ({ + name: getRandomArrayElement(NAMES), + message: getRandomArrayElement(MESSAGES), + description: getRandomArrayElement(DESCRIPTIONS), + id: getRandomArrayElement(id), + url: getRandomArrayElement(url), + likes: getRandomArrayElement(likes), + comments: getRandomArrayElement(comments), + avatar: photos / avatar - { getRandomArrayElement }.jpg +}); + +const similarArray = Array.from({ length: SIMILAR_ARRAY_COUNT }, createArray); + +console.log(similarArray); + + From adba055ce57a523cd831b4324d8f8bdc8f0868df Mon Sep 17 00:00:00 2001 From: Alla Date: Tue, 23 Jun 2026 11:25:03 +0300 Subject: [PATCH 3/3] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=B4=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=D0=BC=204.16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/main.js | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/js/main.js b/js/main.js index b2f2558..572d35e 100644 --- a/js/main.js +++ b/js/main.js @@ -32,13 +32,23 @@ const MESSAGES = [ 'Я поскользнулся на банановой кожуре и уронил фотоаппарат на кота и у меня получилась фотография лучше.', 'Лица у людей на фотке перекошены, как будто их избивают.', 'Как можно было поймать такой неудачный момент ?!' -] +]; const SIMILAR_ARRAY_COUNT = 25; const id = 25; -const likes = 200; -const comments = 30; -const avatar = 25; +const likes = { + MIN: 15, + MAX: 200 +}; +const COMMENTS = 30; +const Avatar = { + MIN: 1, + MAX: 6 +}; +const CommetsId = { + MIN: 10000, + MAX: 1_000_000 +}; const getRandomInteger = (a, b) => { const lower = Math.ceil(Math.min(a, b)); @@ -50,18 +60,22 @@ const getRandomInteger = (a, b) => { const getRandomArrayElement = (elements) => elements[getRandomInteger(0, elements.length - 1)]; -const createArray = () => ({ +const getComment = () => ({ + id: getRandomInteger(CommetsId.MIN, CommetsId.MAX), name: getRandomArrayElement(NAMES), message: getRandomArrayElement(MESSAGES), + avatar: `./img/avatar-${getRandomInteger(Avatar.MIN, Avatar.MAX)}.svg` +}); + +const createArray = (i) => ({ description: getRandomArrayElement(DESCRIPTIONS), - id: getRandomArrayElement(id), - url: getRandomArrayElement(url), - likes: getRandomArrayElement(likes), - comments: getRandomArrayElement(comments), - avatar: photos / avatar - { getRandomArrayElement }.jpg + id: i, + url: `./pictures/${i}.jpg`, + likes: getRandomInteger(Likes.MIN, Likes.MAX), + comments: Array.from({ length: getRandomInteger(0, COMMENTS) }, getComment) }); -const similarArray = Array.from({ length: SIMILAR_ARRAY_COUNT }, createArray); +const similarArray = Array.from({ length: SIMILAR_ARRAY_COUNT }, (_, i) => createArray(i + 1)); console.log(similarArray);