Skip to content

Conversation

@bartoszdudziak-dev
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.

Bartku,

Rozwiązanie są ok 👍
Znalazłem jednak parę błędów (postaraj się poprawić) i zostawiłem kilka sugestii :)

Comment on lines 9 to 29
const result1 = Number(a) + Number(b);
const result2 = Number(a) - Number(b);
const result3 = Number(a) * Number(b);
const result4 = Number(a) / Number(b);
const result5 = Number(a) % Number(b);

console.log(
result1 > 20 ? "Result1 is greater than 20" : "Result1 is less than 20"
);
console.log(
result2 > 20 ? "Result2 is greater than 20" : "Result2 is less than 20"
);
console.log(
result3 > 20 ? "Result3 is greater than 20" : "Result3 is less than 20"
);
console.log(
result4 > 20 ? "Result4 is greater than 20" : "Result4 is less than 20"
);
console.log(
result5 > 20 ? "Result5 is greater than 20" : "Result5 is less than 20"
);
Copy link
Owner

Choose a reason for hiding this comment

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

Jest zgodnie z treścią zadania, ale można by było to usprawnić. Wygodniej by było zapisywać wyniki do tablicy i potem wykorzystać pętlę do wyświetlania danych. Zdecydowanie zgrabniejsze rozwiązanie ;)

02/app.js Outdated
const x = 4;
const x = prompt("Type number: ");

if (x) {
Copy link
Owner

Choose a reason for hiding this comment

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

Tu nie wystarczające sprawdzenie - wystarczy podać znak i już obliczanie nie działa.

02/app.js Outdated
Comment on lines 17 to 21
while (!a) {
a = Number(prompt("Podstawa: "));

while (!n || n <= 1) {
n = Number(prompt("Wykladnik:"));
Copy link
Owner

Choose a reason for hiding this comment

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

Tutaj podobnie. Podajemy dowolny znak, a potem poprawny i już nie liczy :P

const sum = getSum(a, b, c);
const even = isEven(sum);

showInfo(sum, even);
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
@@ -0,0 +1,28 @@
function createArray(min, max) {
if (typeof min !== "number" || typeof max !== "number")
Copy link
Owner

Choose a reason for hiding this comment

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

Warto pamiętać, że NaN to też "number". Ale NaN === NaN => false - można to wykorzystać ;)

05/app.js Outdated
Comment on lines 16 to 23
const calcAverage = (grades) =>
grades.reduce((acc, cur) => acc + cur, 0) / grades.length;

if (typeof subject === "undefined") {
const grades = Object.values(this.grades).flat();
return Number(calcAverage(grades).toFixed(2));
}

Copy link
Owner

Choose a reason for hiding this comment

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

Bardzo fajne rozwiązanie!

PS. Jeszcze sprawdziłbym czy grades nie jest pustą tablicą, bo inaczej dzielimy przez 0

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.

Bartku,

Teraz jest super!

console.log(
`${a} ${operation} ${b} is ${result > 20 ? "greater" : "less"} than 20`
);
});
Copy link
Owner

Choose a reason for hiding this comment

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

👍

}
counter++;
}

Copy link
Owner

Choose a reason for hiding this comment

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

👍


if (min > max) {
throw new Error("min must be less than or equal to max.");
}
Copy link
Owner

Choose a reason for hiding this comment

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

👍

const calcAverage = (grades) => {
if (!grades || grades.length === 0) throw new Error("No grades found!");
return grades.reduce((acc, cur) => acc + cur, 0) / 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.

👍

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