Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="ru">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
Expand Down Expand Up @@ -162,7 +163,7 @@ <h2 class="big-picture__title visually-hidden">Просмотр фотогра
</li>
<li class="social__comment">
<img class="social__picture" src="img/avatar-3.svg" alt="Аватар комментатора фотографии" width="35" height="35">
<p class="social__text">Да это фоташоп!!!!!!!!</p>
<p class="social__text">Да это фоташоп!!!!!!!!</p>
</li>
</ul>

Expand Down Expand Up @@ -227,12 +228,13 @@ <h2 class="success__title">Изображение успешно загруже
</section>
</template>

<!-- Сообщение с ошибкой загрузки изображений от других пользователей -->
<template id="data-error">
<section class="data-error">
<h2 class="data-error__title">Не удалось загрузить данные</h2>
</section>
</template>

<!-- Сообщение с ошибкой загрузки изображений от других пользователей -->
<template id="data-error">
<section class="data-error">
<h2 class="data-error__title">Не удалось загрузить данные</h2>
</section>
</template>
<script src="js/functions.js"></script>
</body>

</html>
54 changes: 54 additions & 0 deletions js/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Функция для проверки длины строки.

const stringLength = (string, maxLelgth) => {
if (string.length <= maxLelgth) {
return true;
}
return false;
};

// Строка короче 20 символов
stringLength('проверяемая строка', 20); // true
// Длина строки ровно 18 символов
stringLength('проверяемая строка', 18); // true
// Строка длиннее 10 символов
stringLength('проверяемая строка', 10); // false


// Функция для проверки, является ли строка палиндромом.

const isPalindrom = (string) => {
const optimizedString = string.replaceAll(' ', '').toLowerCase();

let newString = '';

for (let i = optimizedString.length - 1; i >= 0; i--) {
newString += optimizedString[i];
}
return newString === optimizedString;
};

console.log(isPalindrom('топот')); // true

Check failure on line 31 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
console.log(isPalindrom('ДовОд')); // true

Check failure on line 32 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
console.log(isPalindrom('Кекс')); // false

Check failure on line 33 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
console.log(isPalindrom('Лёша на полке клопа нашёл ')); // true

Check failure on line 34 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement


const getNumber = (string) => {
const numberString = string.toString().replace(/\D/g, '');
return parseInt(numberString, 10);
};

console.log(getNumber('2023 год')); // 2023

Check failure on line 42 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
console.log(getNumber('ECMAScript 2022')); // 2022

Check failure on line 43 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
console.log(getNumber('1 кефир, 0.5 батона')); // 105

Check failure on line 44 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
console.log(getNumber('агент 007')); // 7

Check failure on line 45 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
console.log(getNumber('а я томат')); // NaN

Check failure on line 46 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement

console.log(getNumber(2023)); // 2023

Check failure on line 48 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
console.log(getNumber(-1)); // 1
console.log(getNumber(1.5)); // 15

// метод Match тоже можно))) Проверил с методом replace возвращает всё корректно
// Как перебрать с помощью цикла не разобрался, если возможно покажи пожалуйсто