Skip to content

Commit

Permalink
добавляет тренировочные функции
Browse files Browse the repository at this point in the history
  • Loading branch information
YouAreNotReady committed Nov 18, 2024
1 parent 21c0763 commit 28d8ce6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,5 +234,6 @@ <h2 class="data-error__title">Не удалось загрузить данны
</section>
</template>

<script src="/js/functions.js"></script>
</body>
</html>
24 changes: 24 additions & 0 deletions js/functions.js
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 28d8ce6

Please sign in to comment.