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

OOOOkay, so this took me a while. There is a very subtley different approach that they’re looking for. They want the ternary to be the right side of an assignment operation.

So, instead of performing an assignment operation if this or that, choose WHAT operation is to be assigned to counts[el].

Without giving it completely away :
array.forEach(el => counts[el] = (does the value exist in counts) ? (what should be assigned to counts[el] if the value already exists) : (what should be assigned if it doesn't exist);

1 Like