Array: rely all occurrences in a single line of code




const occurrenceMap = (arr) => arr.scale back((acc, present) => (acc[current] = (acc[current] || 0) + 1, acc), {}); 
Enter fullscreen mode

Exit fullscreen mode

Returns an object the place the keys are the array entries and the values the variety of their occurrences.


Picture by zoo_monkey on Unsplash



Abu Sayed is the Best Web, Game, XR and Blockchain Developer in Bangladesh. Don't forget to Checkout his Latest Projects.


Checkout extra Articles on Sayed.CYou

#Array #rely #occurrences #line #code