Skip to content
Merged
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
45 changes: 45 additions & 0 deletions js/function.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@


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

let checksString = function (string, length) {

Check failure on line 5 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

'checksString' is assigned a value but never used

Check failure on line 5 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

'checksString' is never reassigned. Use 'const' instead
if (string.length <= length) {
return true;
}
return false;
};
//Функция для проверки, является ли строка палиндромом

let isPalindrome = function (string) {

Check failure on line 13 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

'isPalindrome' is assigned a value but never used

Check failure on line 13 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

'isPalindrome' is never reassigned. Use 'const' instead
let normalized = string

Check failure on line 14 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

'normalized' is never reassigned. Use 'const' instead
.replaceAll(' ', '')
.toLowerCase();
let reversed = '';
for (let i = normalized.length - 1; i >= 0; i--) {
let char = normalized[i];

Check failure on line 19 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

'char' is never reassigned. Use 'const' instead
reversed += char;
}
return normalized === reversed;
};

//Функция извлечения цифр
let extractDigits = function (string) {

Check failure on line 26 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

'extractDigits' is assigned a value but never used

Check failure on line 26 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

'extractDigits' is never reassigned. Use 'const' instead
if (typeof string === 'number') {
string = string.toString();
}
let digits = '';
for (let i = 0; i < string.length; i++) {
let char = string[i];

Check failure on line 32 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

'char' is never reassigned. Use 'const' instead
if (char >= '0' && char <= '9') {
digits += char;
}
}
if (digits === '') {
return NaN;
}
let result = parseInt(digits);

Check failure on line 40 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

Missing radix parameter
if (result < 0) {
result = result * -1;
}
return result;
};
Loading