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
Sep 17, 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>
</body>
</html>
22 changes: 22 additions & 0 deletions js/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function checkStringLength (string, maxLength) {

Check failure on line 1 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'checkStringLength' 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.

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

const currentLength = string.length;

if (currentLength <= maxLength) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

излишнее удлинение кода
можно сразу вернуть результат тут

return true;
}

return false;
}

function checkPalindrome (str) {

Check failure on line 11 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'checkPalindrome' is defined but never used
const normalizedString = str.toLowerCase().replaceAll(' ', '');
let newString = '';
const currentLength = normalizedString.length;

for (let currentIndex = currentLength - 1; currentIndex >= 0; currentIndex--) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

хочу разворот "методов массива"

let currentSymbol = normalizedString[currentIndex];

Check failure on line 17 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'currentSymbol' is never reassigned. Use 'const' instead
newString += currentSymbol;
}

return(newString === normalizedString);
Copy link
Collaborator

Choose a reason for hiding this comment

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

скобки в данном случае не нужны, но точно нужен пробел

}
Loading