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

Tell us what’s happening:

I dont why it cant be passed.
const getMode = (array) => {
const counts = {};
array.forEach(el => counts[el] ? counts[el]+=1 : counts[el]=1);
return counts;
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0

Challenge Information:

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

Hi there!

Try with assignment operator like in given example in the challenge instructions.

Hello … you should put assign operator = after your first counts[el].
this = operator assign your counts[el] as a condition and when you write your condition like this (el => counts[el] = then you write your condition which is counts[el] ? counts[el] + 1: 1); that’s it.
Remember freeCodeCamp teaches you try different method and want you to learn different method because this is your learning time . otherwise you can write any function as your want . write it an old method or in ES6 arrow function .
Ok Bye Happy Coding !. :slightly_smiling_face:

5 Likes

Thanks bro, you helped me find the logic :slight_smile: