Learn Advanced Array Methods by Building a Statistics Calculator - Step 35

I have tried rewriting this a 10000 times - what am I doing wrong?

Please assist:

const getMode = (array) => {
const counts = {};
array.forEach(el => counts[el] ? counts[el] += 1 : counts[el] = 1);
return counts;
};

Hello there and welcome to our forum.
Kindly include a link to this lesson.

1 Like

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge. This button only appears if you have tried to submit an answer at least three times.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.