From bcbfd091d96fbf5b502a4a929cb5f586cfd4520b Mon Sep 17 00:00:00 2001 From: Anna Date: Wed, 25 Sep 2024 02:10:50 +0500 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=B72?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/functions.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 js/functions.js diff --git a/js/functions.js b/js/functions.js new file mode 100644 index 0000000..b390b7b --- /dev/null +++ b/js/functions.js @@ -0,0 +1,21 @@ +function checkLenght (string, maxLength) { + if (string.length <= maxLength) { + return true; + } else { + return false; + } +} +console.log(checkLenght('проверяемая строка', 10)); + +function isPalingrome (string) { + string = string.replaceAll(' ', ''); + string = string.toLowerCase(); + reverseString = ''; + for (let i = string.length - 1; i >= 0; i--) { + reverseString+=string[i]; + } + if (reverseString === string) { + return true; + } + return false; +}