Skip to content

Commit

Permalink
Merge pull request #2 from ClaireFotina/module2-task1
Browse files Browse the repository at this point in the history
  • Loading branch information
keksobot authored Oct 17, 2024
2 parents 3f9ba45 + 7f84cdc commit 21a41ef
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions js/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//task 1

const checkLength = (text, maxLength) => text.length <= maxLength;

Check failure on line 3 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'checkLength' is assigned a value but never used

//console.log(checkLength('gjglh', 10))


// task 2

const checkPalindrome = (text) => {

Check failure on line 10 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'checkPalindrome' is assigned a value but never used
const currentText = text.replaceAll(' ', '').toLowerCase();

Check failure on line 11 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Expected indentation of 2 spaces but found 4
let palindrome = '';

Check failure on line 12 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Expected indentation of 2 spaces but found 4

for (let i = currentText.length - 1; i >= 0; i--) {

Check failure on line 14 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Expected indentation of 2 spaces but found 4
palindrome = palindrome + currentText.at(i);

Check failure on line 15 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Expected indentation of 4 spaces but found 8
}

Check failure on line 16 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Expected indentation of 2 spaces but found 4

return palindrome === currentText;
}

Check failure on line 19 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Missing semicolon

//console.log(checkPalindrome('Шалаш'))

//task 3

const cutNumber = (text) => {

Check failure on line 25 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'cutNumber' is assigned a value but never used
const currentText = String(text);
let number = '';
for (let i = 0; i < currentText.length; i++) {
if (!Number.isNaN(parseInt(currentText.at(i), 10))) {
number = number + currentText.at(i);
}
}

return parseInt(number, 10);
}

Check failure on line 35 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Missing semicolon

//console.log(cutNumber('dhjlh4 hlfgh3 f7 j e8'))

// 4378

0 comments on commit 21a41ef

Please sign in to comment.