Skip to content

Commit

Permalink
нужно больше функций
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlNik committed Nov 29, 2024
1 parent b3eb9d5 commit ed0a6fe
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<script src="/js/functions.js"></script>
<title>Кекстаграм</title>
</head>

Expand Down
46 changes: 46 additions & 0 deletions js/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
function checkLengthString(string = '', length = 1) {

Check failure on line 1 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'checkLengthString' is defined but never used
return (string <= length);
}
console.log(checkStringLength('тестовая строка', 5));

Check failure on line 4 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement

Check failure on line 4 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'checkStringLength' is not defined

function findPolydrome(string = '') {

Check failure on line 6 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'findPolydrome' is defined but never used
string = string.replaceAll(' ', '').toLowerCase();

let reversedLength = '';

for (let i = string.length - 1; i >= 0; i--) {
reversedLength += string[1];
}

return string === reversedLength;
}

// Функция принимает строку,
// извлекает содержащиеся в ней цифры от 0 до 9 и возвращает их в виде целого положительного числа. Если в строке нет ни одной цифры, функция должна вернуть NaN:

function extractsNumbers(string = '') {

let str = '';
let newStr = string.toString();

Check failure on line 24 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'newStr' is never reassigned. Use 'const' instead

for (let i = 0; i <= newStr.length - 1; i++) {
if (parseInt(newStr[i]) || parseInt(newStr[i]) === 0) {

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 27 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Missing radix parameter
str += newStr[i];
}
}

if (str) {
let num = Number(str);

Check failure on line 33 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'num' is never reassigned. Use 'const' instead
return Math.abs(num);
} else {
return NaN;
}

}

console.log(extractsNumbers('2023 год'));

Check failure on line 41 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
console.log(extractsNumbers('ECMAScript 2022'));

Check failure on line 42 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
console.log(extractsNumbers('1 кефир, 0.5 батона'));
console.log(extractsNumbers('агент 007'));
console.log(extractsNumbers('а я томат'));
console.log(extractsNumbers(-1));

0 comments on commit ed0a6fe

Please sign in to comment.