From 28d8ce65288f06b7c9a37cd9e38faac2ebaf190a Mon Sep 17 00:00:00 2001 From: Vladimir Gankin Date: Mon, 18 Nov 2024 10:26:45 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D1=82=20=D1=82=D1=80=D0=B5=D0=BD=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=BE=D1=87=D0=BD=D1=8B=D0=B5=20=D1=84=D1=83=D0=BD=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 1 + js/functions.js | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 js/functions.js diff --git a/index.html b/index.html index 9fb6740..08296e2 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..4b56464 --- /dev/null +++ b/js/functions.js @@ -0,0 +1,24 @@ +function isLesserOrEqual(string, maxLength) { + return string.length <= maxLength; +} + +function isPalindrome(string) { + let normalizedString = string.replaceAll(" ", "").toLowerCase(); + let reversedString = normalizedString.split("").reverse().join(""); + + return normalizedString === reversedString; +} + +function toPositiveNumber(string) { + let normalizedString = string.toString().replaceAll(" ", ""); + let result = ""; + + for (let i = 0; i < normalizedString.length; i++) { + if(!isNaN(Number(normalizedString[i]))) { + result += normalizedString[i]; + } + } + + return parseInt(result); +} +