-
Notifications
You must be signed in to change notification settings - Fork 1
Нужно больше функций #3
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
Нужно больше функций #3
Conversation
|
♻️ Я собрал ваш пулреквест. Посмотреть можно здесь. |
js/functions.js
Outdated
| const isLessOrEqual = (testString, amountSymbols) =>{ | ||
| if (testString.length <= amountSymbols){ | ||
| return true; | ||
| }else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не используем условия если результат ожидается boolen - возвращаем логическое выражение
return testString.length <= amountSymbols;
js/functions.js
Outdated
|
|
||
| const isPalindrom = (text) =>{ | ||
| const unspacedText = text.replaceAll(' ', ''); | ||
| const normalizedText = unspacedText.toUpperCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Полезно применить цепочку, так как нет необходимости в промежуточной константе
const normalizedText = text.replaceAll(' ', '').toUpperCase();
js/functions.js
Outdated
| const unspacedText = text.replaceAll(' ', ''); | ||
| const normalizedText = unspacedText.toUpperCase(); | ||
| let reversedText = ''; | ||
| for (let lastIndex = normalizedText.length - 1; lastIndex >= 0 ; lastIndex --) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- команды явного присвоения более удобные для чтения
длинная запись
lastIndex = lastIndex - 1
короткая, которая принята в общей практике
lastIndex -= 1
- название индекса
НазваниеlastIndeexсложно ассоциировать с реальным назначением. Фактически, это просто "индекс" - индексы в циклах принято называть односимвольными названиями, по порядку вложенности циклов:i,j,n,m
Т.е., если цикл основной или единственный - индекс всегда именуется i
js/functions.js
Outdated
| for (let lastIndex = normalizedText.length - 1; lastIndex >= 0 ; lastIndex --) { | ||
| reversedText += normalizedText.at(lastIndex); | ||
| } | ||
| if(normalizedText === reversedText){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вернуть можно результат логического выражения - условие не требуется
|
♻️ Я собрал ваш пулреквест. Посмотреть можно здесь. |
🎓 Нужно больше функций
💥 https://htmlacademy-javascript.github.io/2607777-kekstagram-2/3/