Skip to content

Commit 00f890a

Browse files
authored
Merge pull request #2 from YouAreNotReady/module2-task1
2 parents 237287c + 2fab576 commit 00f890a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,5 +234,6 @@ <h2 class="data-error__title">Не удалось загрузить данны
234234
</section>
235235
</template>
236236

237+
<script src="/js/functions.js"></script>
237238
</body>
238239
</html>

js/functions.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function isLesserOrEqual(string, maxLength) {
2+
return string.length <= maxLength;
3+
}
4+
5+
function isPalindrome(string) {
6+
const normalizedString = string.replaceAll(' ', '').toLowerCase();
7+
const reversedString = normalizedString.split('').reverse().join('');
8+
9+
return normalizedString === reversedString;
10+
}
11+
12+
function toPositiveNumber(string) {
13+
const normalizedString = string.toString().replaceAll(' ', '');
14+
let result = '';
15+
16+
for (let i = 0; i < normalizedString.length; i++) {
17+
if(!isNaN(Number(normalizedString[i]))) {
18+
result += normalizedString[i];
19+
}
20+
}
21+
22+
return parseInt(result, 10);
23+
}
24+

0 commit comments

Comments
 (0)