Skip to content

Commit db85abc

Browse files
authored
Merge pull request #3 from natalya87324/module2-task1
Нужно больше функций
2 parents f2296f4 + c99397d commit db85abc

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const isLengthValid = (str = '', maxLength = 0) => str.length <= maxLength;
2+
3+
isLengthValid('Hello World', 20);
4+
5+
const isPalindrom = (str = '') => {
6+
const normalizedStr = str.replaceAll(' ', '').toLowerCase();
7+
let reversedStr = '';
8+
9+
for (let i = normalizedStr.length - 1; i >= 0; i--) {
10+
reversedStr += normalizedStr[i];
11+
}
12+
13+
return normalizedStr === reversedStr;
14+
};
15+
16+
isPalindrom();

0 commit comments

Comments
 (0)