-
Notifications
You must be signed in to change notification settings - Fork 206
Complete all tasks #168
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
base: master
Are you sure you want to change the base?
Complete all tasks #168
Conversation
devmentor-pl
left a comment
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.
Sandro,
Tutaj również ok 👍
Zwróciłem uwagę na 2 rzeczy, które warto poprawić ;)
| } else { | ||
| console.log(`${result.name} is less than or equal to 20`) | ||
| } | ||
| } |
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 results = x * i; | ||
| console.log(`${x} x ${i} = ${results}`); | ||
| } | ||
| } |
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.
👍
| i++; | ||
| } | ||
| console.log(`${sequence} = ${result}`); | ||
| } |
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.
👍
| console.log(`Podany argument ${sum} jest nieparzysty`); | ||
| } | ||
| } | ||
| const completeInfo = showInfo(sum, isSumEven); |
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.
👍
04/app.js
Outdated
|
|
||
|
|
||
| function arithmeticMean(arr) { | ||
| return arr.reduce((acc, curr) => acc + curr, 0) / arr.length; |
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.
Warto też sprawdzić czy tablica nie jest pusta, aby nie dzielić przez 0 :)
05/app.js
Outdated
| if (!grades || grades.length === 0) return 0; | ||
| const sum = grades.reduce((acc, val) => acc + val, 0); | ||
| return sum /grades.length; |
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.
Zwróć uwagę, że te 3 linie są praktycznie identyczne do tych z 29-31. W takiej sytuacji warto sprobować napisać funkcję/metodę, którą wykorzystasz w obu miejscach.
devmentor-pl
left a comment
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.
Sandro,
Super, o to chodziło! 👍
Zostawiłem też istotny komentarz do przeanalizowania ;)
04/app.js
Outdated
| if( arr.length !== 0) { | ||
| return arr.reduce((acc, curr) => acc + curr, 0) / arr.length; | ||
| } else { | ||
| return 0; | ||
| } |
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.
Można też tak (chyba trochę czytelniej):
if(arr.length === 0) {
return 0;
}
return arr.reduce((acc, curr) => acc + curr, 0) / arr.length;
Tak, łatwiej złapać kontekst po rzuceniu okiem (taka niesubiektywna opinia).
Moja wersja: Jeśli brak elementów to zwróć 0, w przeciwnym razie oblicz sumę
Twoja wersja: Jeśli NIE ma braku elementów to oblicz sumę, w przeciwnym razie zwróć 0
| if (!grades || grades.length === 0) return 0; | ||
| const sum = grades.reduce((acc, val) => acc + val, 0); | ||
| return sum /grades.length; | ||
| return this.calculateAverage(this.grades[subject]); |
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.
Super! Zobacz jak bardzo zwiększyła się czytelność!
No description provided.