From 77e1154bea41950b6688dbf38209f4763222037c Mon Sep 17 00:00:00 2001 From: Vladimir Gankin Date: Mon, 18 Nov 2024 10:26:45 +0300 Subject: [PATCH 1/3] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D1=8F=D0=B5?= =?UTF-8?q?=D1=82=20=D1=82=D1=80=D0=B5=D0=BD=D0=B8=D1=80=D0=BE=D0=B2=D0=BE?= =?UTF-8?q?=D1=87=D0=BD=D1=8B=D0=B5=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=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); +} + From 28d8ce65288f06b7c9a37cd9e38faac2ebaf190a Mon Sep 17 00:00:00 2001 From: Vladimir Gankin Date: Mon, 18 Nov 2024 10:26:45 +0300 Subject: [PATCH 2/3] =?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); +} + From 2fab5760d7e962d65158b0f295ab9920985b0066 Mon Sep 17 00:00:00 2001 From: Vladimir Gankin Date: Mon, 18 Nov 2024 10:35:21 +0300 Subject: [PATCH 3/3] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D1=82=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D0=BB=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/functions.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/functions.js b/js/functions.js index 4b56464..47f6aad 100644 --- a/js/functions.js +++ b/js/functions.js @@ -3,15 +3,15 @@ function isLesserOrEqual(string, maxLength) { } function isPalindrome(string) { - let normalizedString = string.replaceAll(" ", "").toLowerCase(); - let reversedString = normalizedString.split("").reverse().join(""); + const normalizedString = string.replaceAll(' ', '').toLowerCase(); + const reversedString = normalizedString.split('').reverse().join(''); return normalizedString === reversedString; } function toPositiveNumber(string) { - let normalizedString = string.toString().replaceAll(" ", ""); - let result = ""; + const normalizedString = string.toString().replaceAll(' ', ''); + let result = ''; for (let i = 0; i < normalizedString.length; i++) { if(!isNaN(Number(normalizedString[i]))) { @@ -19,6 +19,6 @@ function toPositiveNumber(string) { } } - return parseInt(result); + return parseInt(result, 10); }