Conversation
Romapsp
commented
Sep 29, 2024
Owner
- Renamed a file due to initial mistake (thus it has been replaced)
- completed tasks 1-2 of hw7
anatoly-karpovich
approved these changes
Sep 29, 2024
Comment on lines
+8
to
+14
| for (let i = 0; i < competitorPizzas.length; i++) { | ||
| competitorPizzas[i] = competitorPizzas[i].toLowerCase() | ||
| } | ||
|
|
||
| for (let i = 0; i < myPizzas.length; i++) { | ||
| myPizzas[i] = myPizzas[i].toLowerCase() | ||
| } |
Collaborator
There was a problem hiding this comment.
по факту ты меняешь изначальные массивы, потому может и есть смысл создавать отдельные переменные под массивы пицц в нижнем регистре
Comment on lines
+22
to
+26
| if (pizzaResult.length === 0) { | ||
| console.log(null) | ||
| } else { | ||
| console.log(pizzaResult) | ||
| } No newline at end of file |
Collaborator
There was a problem hiding this comment.
Suggested change
| if (pizzaResult.length === 0) { | |
| console.log(null) | |
| } else { | |
| console.log(pizzaResult) | |
| } | |
| console.log(pizzaResult.length ? pizzaResult : null) |
Comment on lines
+12
to
+29
| function derive(text) { | ||
| let result = text.replaceAll(' ', '_') | ||
| let finalResult = '' | ||
|
|
||
| for (let i = 0; i < result.length; i++) { | ||
| if (result[i] === '_') { | ||
| finalResult += '_' | ||
| if (i + 1 < result.length) { | ||
| finalResult += result[i + 1].toUpperCase() | ||
| i++ | ||
| } | ||
| } else { | ||
| finalResult += result[i] | ||
| } | ||
| } | ||
|
|
||
| return finalResult[0].toLowerCase() + finalResult.slice(1) | ||
| } |
Collaborator
There was a problem hiding this comment.
Это сильно:) а почему бы не использовать .split и после .join?)
| competitorPizzas[i] = competitorPizzas[i].toLowerCase() | ||
| const normalizedWord = word.toLowerCase(); | ||
|
|
||
| const reversedWord = normalizedWord.split('').reverse().join(''); |
Collaborator
There was a problem hiding this comment.
а вот это хорошо!
VladimirLQA
reviewed
Sep 29, 2024
|
|
||
| // showArgs([1, 2],[3, 4], [5, 6]) | ||
|
|
||
| function derive(text) { |
Collaborator
There was a problem hiding this comment.
Попробуй решить таким вариантом
- сплитуем аргумент по пробелам
- итерируемся по получившемуся массиву с помощью мапа приводя первую букву к верхнему регистру, если необходимо
- вьіполняем джоин
По идее такой подход будет более прямолинейньім, убирая дополнимельньіе if вьіражения и лишнии мутации стринги
И возможно будет такой случай, что на вход будет подана такая строка I aM suPer EngInEeR
Посмотри какой результат будет :)
VladimirLQA
approved these changes
Sep 29, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.