Skip to content

add tasks 1-5#174

Open
MagdalenaKoltuniak wants to merge 6 commits intodevmentor-pl:masterfrom
MagdalenaKoltuniak:master
Open

add tasks 1-5#174
MagdalenaKoltuniak wants to merge 6 commits intodevmentor-pl:masterfrom
MagdalenaKoltuniak:master

Conversation

@MagdalenaKoltuniak
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Owner

@devmentor-pl devmentor-pl left a comment

Choose a reason for hiding this comment

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

Magdo,

Zostawiłem jedynie jedną drobną uwagę ;) 👍

} else {
console.log(`${el} jest mniejsze od 20`);
}
});
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍


/* rozwiązanie z pętlą while */ No newline at end of file
console.log(`${text} = ${result}`);
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

return [intNum1, intNum2, intNum3]
.sort((a, b) => a - b)
.slice(-2)
.reduce((acc, curr) => acc + curr, 0);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Super!


function getAvg(array) {
return array.reduce((acc, curr) => acc + curr, 0) / array.length;
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

05/app.js Outdated
for (const sub in this.grades) {
newArr.push(...this.grades[sub]);
}
return Number((newArr.reduce((acc, curr) => acc + curr, 0) / newArr.length).toFixed(2));
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Tutaj mamy dość podobny kod do tego z linii 26. Warto napisać wspólną metodę/funkcję i ją wykorzystać w obu miejscach.

Copy link
Copy Markdown
Owner

@devmentor-pl devmentor-pl left a comment

Choose a reason for hiding this comment

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

Magdo,

Super, o to chodziło! 👍


Student.prototype.calculateAverage = function (arr) {
return Number((arr.reduce((acc, curr) => acc + curr, 0) / arr.length).toFixed(2));
};
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Zdecydowanie lepiej! Teraz jak będzie trzeba obliczać inaczej średnią - np. podawać 3 miejsca po przecinku to nie będzie to żaden problem. Najważniejsze, że taka zmiana będzie dotyczyć tylko jednego miejsca i zawsze staramy się do tego dążyć.

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.

2 participants