Tell us what’s happening:
Hi guys! can you help me check my code?
I am confident that I did it correctly, but still say’s
'Your function should still increment the counts variable properly.
I tried different approach:
counts[el] === true ? counts += 1 : counts = 1 //Space or no spaces
counts[el]?counts++:counts=1
Your code so far
/* file: script.js */
// User Editable Region
const getMode = (array) => {
const counts = {};
array.forEach(el => counts[el]===true? 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
Challenge Information:
Learn Advanced Array Methods by Building a Statistics Calculator - Step 35