diff --git a/index.html b/index.html index 9fb6740..1737192 100644 --- a/index.html +++ b/index.html @@ -234,5 +234,6 @@

Не удалось загрузить данны + diff --git a/js/functions.js b/js/functions.js new file mode 100644 index 0000000..038eb98 --- /dev/null +++ b/js/functions.js @@ -0,0 +1,22 @@ +function checkStringLength (string, maxLength) { + const currentLength = string.length; + + if (currentLength <= maxLength) { + return true; + } + + return false; +} + +function checkPalindrome (str) { + const normalizedString = str.toLowerCase().replaceAll(' ', ''); + let newString = ''; + const currentLength = normalizedString.length; + + for (let currentIndex = currentLength - 1; currentIndex >= 0; currentIndex--) { + let currentSymbol = normalizedString[currentIndex]; + newString += currentSymbol; + } + + return(newString === normalizedString); +}