Skip to content

Commit

Permalink
дополняет домашнее задание
Browse files Browse the repository at this point in the history
  • Loading branch information
KateSolodchuk committed Sep 28, 2024
1 parent cdef186 commit f02a277
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions js/functions.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
function checkStringLength (string, maxLength) {
const currentLength = string.length;

if (currentLength <= maxLength) {
const checkStringLength = (string, maxLength) => {

Check failure on line 1 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'checkStringLength' is assigned a value but never used
if (string.length <= maxLength) {
return true;
}

return false;
}
};

function checkPalindrome (str) {
const normalizedString = str.toLowerCase().replaceAll(' ', '');
const checkPalindrome = (string) => {

Check failure on line 9 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'checkPalindrome' is assigned a value but never used
const normalizedString = string.toLowerCase().replaceAll(' ', '');
let newString = '';
const currentLength = normalizedString.length;

for (let currentIndex = currentLength - 1; currentIndex >= 0; currentIndex--) {
let currentSymbol = normalizedString[currentIndex];
newString += currentSymbol;
for (let currentIndex = normalizedString.length - 1; currentIndex >= 0; currentIndex--) {
newString += normalizedString[currentIndex];
}

return newString === normalizedString;
};

const getNumbers = (string) => {

Check failure on line 20 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'getNumbers' is assigned a value but never used
let result = '';
string = string.toString();

for (let i = 0; i <= string.length - 1; i++) {
if (Number.isNaN(parseInt(string[i], 10)) === false) {
result += string[i];
}
}

return(newString === normalizedString);
}
return result === '' ? NaN : parseInt(result, 10);
};

0 comments on commit f02a277

Please sign in to comment.