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 1 commit into from
Oct 17, 2024
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
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
Loading