Skip to content

Conversation

@MstowskaSandra
Copy link

No description provided.

Copy link
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.

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`)
}
}
Copy link
Owner

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}`);
}
}
Copy link
Owner

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}`);
}
Copy link
Owner

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);
Copy link
Owner

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;
Copy link
Owner

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
Comment on lines 24 to 26
if (!grades || grades.length === 0) return 0;
const sum = grades.reduce((acc, val) => acc + val, 0);
return sum /grades.length;
Copy link
Owner

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.

Copy link
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.

Sandro,

Super, o to chodziło! 👍
Zostawiłem też istotny komentarz do przeanalizowania ;)

04/app.js Outdated
Comment on lines 23 to 27
if( arr.length !== 0) {
return arr.reduce((acc, curr) => acc + curr, 0) / arr.length;
} else {
return 0;
}
Copy link
Owner

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]);
Copy link
Owner

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ść!

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