-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ee9878
commit 5c6dd1e
Showing
2 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const checkLength = (string, length) => { | ||
if(string.length <= length){ | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}; | ||
|
||
checkLength('проверяемая строка', 18); | ||
|
||
|
||
const isPalindromeString = (string) => { | ||
const newString = string.replaceAll(' ','').toLowerCase(); | ||
|
||
let invertedString = ''; | ||
for(let i = newString.length - 1; i >= 0; i--){ | ||
invertedString += newString[i]; | ||
} | ||
|
||
if(newString === invertedString){ | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}; | ||
|
||
isPalindromeString('Лёша на полке клопа нашёл '); | ||
|
||
const getNumber = (string) => { | ||
|
||
const replacedString = string.replaceAll(' ',''); | ||
let numberString = ''; | ||
|
||
for(let i = 0; i <= replacedString.length - 1; i++){ | ||
if(isNaN(replacedString[i]) === false){ | ||
|
||
if(replacedString[i] < 0){ | ||
numberString += Math.abs(replacedString[i]); | ||
} | ||
|
||
numberString += replacedString[i]; | ||
} | ||
} | ||
if(numberString === ''){ | ||
return NaN; | ||
} | ||
const number = Number(numberString); | ||
return number; | ||
}; | ||
|
||
getNumber('ECMAScript 2022'); |