Skip to content

Commit

Permalink
complete
Browse files Browse the repository at this point in the history
  • Loading branch information
YaroslavShunikov committed Nov 15, 2024
1 parent 38ff19d commit 3e4955b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions js/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const checkStringLenght = (textToValidate, maxLenght) => textToValidate.lenght <= maxLenght;

checkStringLenght('fffffff', 18);


function isPalindrom (string){
const cleaned = string.replaceAll(' ','').toLowerCase();
const reversed = cleaned.split('').reverse().join('');
return cleaned === reversed;
}

// Строка является палиндромом
isPalindrom('топот'); // true
// Несмотря на разный регистр, тоже палиндром
isPalindrom('ДовОд'); // true
// Это не палиндром
isPalindrom('Кекс'); // false
isPalindrom('Лёша на полке клопа нашёл'); //true

0 comments on commit 3e4955b

Please sign in to comment.