Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
skyfxllen committed Nov 20, 2024
1 parent bec6737 commit 3906a63
Showing 1 changed file with 37 additions and 38 deletions.
75 changes: 37 additions & 38 deletions js/function.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,51 @@
function checkMaxLength(string, maxLength){
return string.length <= maxLength;
function checkMaxLength(string, maxLength) {
return string.length <= maxLength;
}
// Cтрока короче 20 символов
checkMaxLength('проверяемая строка', 20); // true
checkMaxLength("проверяемая строка", 20); // true

Check failure on line 5 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

Strings must use singlequote
// Длина строки ровно 18 символов
checkMaxLength('проверяемая строка', 18); // true
checkMaxLength("проверяемая строка", 18); // true

Check failure on line 7 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

Strings must use singlequote
// Строка длиннее 10 символов
checkMaxLength('проверяемая строка', 10); // false
checkMaxLength("проверяемая строка", 10); // false

Check failure on line 9 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

Strings must use singlequote


function isPalindrome(word){
if (!word.length){
return ;
}
word = word.toLowerCase()
word = word.replaceAll(' ', '')
let lastLetter = word.length - 1;
for (let i = 0; i <= Math.round(word.length / 2); i++){
if (word[i] != word[lastLetter]){
return false;
} else{
lastLetter -= 1;
}
function isPalindrome(word) {
if (!word.length) {
return;
}
word = word.toLowerCase();
word = word.replaceAll(" ", "");

Check failure on line 16 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

Strings must use singlequote

Check failure on line 16 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

Strings must use singlequote
let lastLetter = word.length - 1;
for (let i = 0; i <= Math.round(word.length / 2); i++) {
if (word[i] != word[lastLetter]) {

Check failure on line 19 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

Expected '!==' and instead saw '!='
return false;
} else {
lastLetter -= 1;
}
return true;
}
return true;
}

// Строка является палиндромом
isPalindrome('топот'); // true
isPalindrome("топот"); // true

Check failure on line 29 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

Strings must use singlequote
// Несмотря на разный регистр, тоже палиндром
isPalindrome('ДовОд'); // true
isPalindrome("ДовОд"); // true

Check failure on line 31 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

Strings must use singlequote
// Это не палиндром
isPalindrome('Кекс'); // false
isPalindrome('Лёша на полке клопа нашёл ');
isPalindrome("Кекс"); // false

Check failure on line 33 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

Strings must use singlequote
isPalindrome("Лёша на полке клопа нашёл ");

Check failure on line 34 in js/function.js

View workflow job for this annotation

GitHub Actions / Check

Strings must use singlequote

function takeNum(string){
let result = '';
let numbers = '0123456789';
for (let i = 0; i < string.length; i++){
if (numbers.includes(string[i])){
result += string[i]
}
function takeNum(string) {
let result = "";
let numbers = "0123456789";
for (let i = 0; i < string.length; i++) {
if (numbers.includes(string[i])) {
result += string[i];
}
return parseInt(result);
}
return parseInt(result);
}

takeNum('2023 год'); // 2023
takeNum('ECMAScript 2022'); // 2022
takeNum('1 кефир, 0.5 батона'); // 105
takeNum('агент 007'); // 7
takeNum('а я томат'); // Nan
takeNum("2023 год"); // 2023
takeNum("ECMAScript 2022"); // 2022
takeNum("1 кефир, 0.5 батона"); // 105
takeNum("агент 007"); // 7
takeNum("а я томат"); // Nan

0 comments on commit 3906a63

Please sign in to comment.