Skip to content

Dmitry plus lesson 13 homework#164

Open
dmitryplus wants to merge 13 commits intonickovchinnikov:masterfrom
dmitryplus:dmitry_plus_lesson-13-homework
Open

Dmitry plus lesson 13 homework#164
dmitryplus wants to merge 13 commits intonickovchinnikov:masterfrom
dmitryplus:dmitry_plus_lesson-13-homework

Conversation

@dmitryplus
Copy link

No description provided.

return maxTeam;
}
},
{ name: "", score: 0 }

Choose a reason for hiding this comment

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

Можно не передавать начальное значение. Тогда reduce возьмет первый элемент

Copy link
Author

Choose a reason for hiding this comment

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

поправил

): string => {
const maxTeam: Team = teams.reduce(
(maxTeam: Team, item: Team) => {
if (item.score > maxTeam.score) {

Choose a reason for hiding this comment

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

Здесь лучше подойдет тернарный оператор

Copy link
Author

Choose a reason for hiding this comment

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

поправил

qs = qs.replace("?", "");

const parser = (str: string, delimeter: string) =>
String(str).split(delimeter);

Choose a reason for hiding this comment

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

str итак строка. Зачем делать объектную обертку String(str)?

Copy link
Author

Choose a reason for hiding this comment

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

проверял в консоли, там нет ts и нужно явно создавать экземпляр строки
тут убрал

const result: ExpectedTeam = {
name: "New York Badgers",
roster: 25,
league: "",

Choose a reason for hiding this comment

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

Здесь лучше сразу присваивать originalTeam.league.
name тоже забираем из originalTeam

Copy link
Author

Choose a reason for hiding this comment

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

присваивание league сделал. но name так нельзя - из Tampa Bay Roosters New York Badgers не получится
тест не проходит

Choose a reason for hiding this comment

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

Понял)

// eslint-disable-next-line
// @ts-ignore
): Team => {
const result: Team = Object.assign({}, originalTeam, {});

Choose a reason for hiding this comment

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

Здесь не происходит глубокое копирование. Только поверхностное

Copy link
Author

Choose a reason for hiding this comment

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

сделал через json

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