Skip to content
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

Нужно больше функций #2

Merged
merged 2 commits into from
Nov 28, 2024
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
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,5 +234,6 @@ <h2 class="data-error__title">Не удалось загрузить данны
</section>
</template>

<script src="js/functions.js"></script>
</body>
</html>
28 changes: 28 additions & 0 deletions js/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Функция для проверки, является ли строка длиннее заданного числа

const isStringLonger = (string = '', maxLength = 1) => string.length <= maxLength;

Check failure on line 3 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'isStringLonger' is assigned a value but never used


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

const isPalindrom = (string = '') => {

Check failure on line 8 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'isPalindrom' is assigned a value but never used
string = string.toLowerCase().replaceAll(' ', '');
let reverseString = '';
for (let i = 0; i < string.length; i++) {
reverseString += string[string.length - 1 - i];
}
return string === reverseString;
}

Check failure on line 15 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Missing semicolon

// Функция для извлечения числа из строки

const extractNumber = (string) => {

Check failure on line 19 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'extractNumber' is assigned a value but never used
string = string.toString();
let number = '';
for (let i = 0; i < string.length; i++) {
if (!isNaN(parseInt(string[i]))) {

Check failure on line 23 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Missing radix parameter
number += string[i];
}
}
return parseInt(number);

Check failure on line 27 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Missing radix parameter
}

Check failure on line 28 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Missing semicolon
Loading