Skip to content
Advertisement

React setState of an object with count

I have an array of integers from 0 to 6 as input I need to return an object with the count of each of those numbers

JavaScript

but I can’t do the function for the set of values

JavaScript

I am expecting this

JavaScript

Can you help me? Thank you very much

Advertisement

Answer

You can use reduce()

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement