Skip to content

add hw7 task 1-2 - #7

Open
Romapsp wants to merge 1 commit into
masterfrom
hw7
Open

add hw7 task 1-2#7
Romapsp wants to merge 1 commit into
masterfrom
hw7

Conversation

@Romapsp

@Romapsp Romapsp commented Sep 29, 2024

Copy link
Copy Markdown
Owner
  • Renamed a file due to initial mistake (thus it has been replaced)
  • completed tasks 1-2 of hw7

@Romapsp Romapsp self-assigned this Sep 29, 2024
Comment thread hw6Task2.js
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()
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

по факту ты меняешь изначальные массивы, потому может и есть смысл создавать отдельные переменные под массивы пицц в нижнем регистре

Comment thread hw6Task2.js
Comment on lines +22 to +26
if (pizzaResult.length === 0) {
console.log(null)
} else {
console.log(pizzaResult)
} No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (pizzaResult.length === 0) {
console.log(null)
} else {
console.log(pizzaResult)
}
console.log(pizzaResult.length ? pizzaResult : null)

Comment thread hw7Task1.js
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)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Это сильно:) а почему бы не использовать .split и после .join?)

Comment thread hw7Task2.js
competitorPizzas[i] = competitorPizzas[i].toLowerCase()
const normalizedWord = word.toLowerCase();

const reversedWord = normalizedWord.split('').reverse().join('');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

а вот это хорошо!

Comment thread hw7Task1.js

// showArgs([1, 2],[3, 4], [5, 6])

function derive(text) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Попробуй решить таким вариантом

  • сплитуем аргумент по пробелам
  • итерируемся по получившемуся массиву с помощью мапа приводя первую букву к верхнему регистру, если необходимо
  • вьіполняем джоин

По идее такой подход будет более прямолинейньім, убирая дополнимельньіе if вьіражения и лишнии мутации стринги
И возможно будет такой случай, что на вход будет подана такая строка I aM suPer EngInEeR
Посмотри какой результат будет :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants