Skip to content

Conversation

@Hadidreem17
Copy link

No description provided.

@dardecena dardecena self-requested a review September 16, 2025 16:22
Copy link

@dardecena dardecena left a comment

Choose a reason for hiding this comment

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

Great effort...almost there. Please try exercise 3 and 5-q4 again.

I added some additional comments. Please reflect on them and keep them in mind for future assignments.

Comment on lines +1 to +13
function doubleEvenNumbers(numbers) {
// TODO rewrite the function body using `map` and `filter`.
return numbers.filter(n => n % 2 === 0).map(n => n * 2);
}
module.exports = doubleEvenNumbers;
// ! Unit test (using Jest)
describe('js-wk3-ex1-doubleEvenNumbers', () => {
test('doubleEvenNumbers should take the even numbers and double them', () => {
const actual = doubleEvenNumbers([1, 2, 3, 4]);
const expected = [4, 8];
expect(actual).toEqual(expected);
});
});

Choose a reason for hiding this comment

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

This seems to be a duplicate file. In the future, please edit assignment and remove redundant code/files before submitting.

}
}
return newNumbers;
return numbers.filter(n => n % 2 === 0).map(n => n * 2);

Choose a reason for hiding this comment

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

Great job using the filter() and map() method 😄

Comment on lines +1 to +4
const eurosFormatter = new Intl.NumberFormat('nl-NL', {
style: 'currency',
currency: 'EUR',
});

Choose a reason for hiding this comment

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

Note: This returns a slightly different format than the expected value on the unit test (eg. '€NBSP187,50')

Comment on lines +11 to +20
function computeEarnings(tasks, hourlyRate) {
const totalMinutes = Array.isArray(tasks)
? tasks.reduce((sum, t) => sum + (Number(t?.duration) || 0), 0)
: 0;

const totalHours = totalMinutes / 60;
const earnings = totalHours * Number(hourlyRate || 0);

return eurosFormatter.format(earnings);
}

Choose a reason for hiding this comment

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

Good job using the reduce() method.

Challenge: How would you rewrite this function if you were to also apply the map() function, and return the required format without using the eurosFormatter() function?

Note: The tests were removed from the file. Please restore them.

@@ -0,0 +1,36 @@
const sanitizeFruitBasket = require('./ex3-lemonAllergy');

Choose a reason for hiding this comment

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

The function sanitizeFruitBasket() seems to be incomplete. Could you try again?

// prettier-ignore
// eslint-disable-next-line no-unused-vars
const quiz = {
q1: { answer: 'b' },

Choose a reason for hiding this comment

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

👍

// eslint-disable-next-line no-unused-vars
const quiz = {
q1: { answer: 'b' },
q2: { answer: 'c' },

Choose a reason for hiding this comment

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

👍

const quiz = {
q1: { answer: 'b' },
q2: { answer: 'c' },
q3: { answer: 'a' },

Choose a reason for hiding this comment

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

👍

q1: { answer: 'b' },
q2: { answer: 'c' },
q3: { answer: 'a' },
q4: { answer: 'b' },

Choose a reason for hiding this comment

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

❌ Please try again.

q2: { answer: 'c' },
q3: { answer: 'a' },
q4: { answer: 'b' },
q5: { answer: 'c' },

Choose a reason for hiding this comment

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

:+1

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