Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Нужно больше функций #2

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

стоит не от корня, а от папки

./js/functions.js

иначе в данном случае на публикованной версии работать не будет - тк не найдет файл "в корне"

</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) {

Check failure on line 1 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'isLesserOrEqual' is defined but never used
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

используем по максимуму стрелочные функции

return string.length <= maxLength;
}

function isPalindrome(string) {

Check failure on line 5 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'isPalindrome' is defined but never used
const normalizedString = string.replaceAll(' ', '').toLowerCase();
const reversedString = normalizedString.split('').reverse().join('');

return normalizedString === reversedString;
}

function toPositiveNumber(string) {

Check failure on line 12 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'toPositiveNumber' is defined but never used
const 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, 10);
}

Loading