// Calculate the number of elements in an array const arr = [1, 5, 5, 3, 1, 5] const result = arr.reduce((prevState, num) => { prevState[num] = prevState[num] ? prevState[num] + 1 : 1 return prevState }, {}) console.log('Result', result) // Result { 1: 2, 3: 1, 5: 3 }
Sajal Mia
Hey there, I am a passionate software engineer, blogger, researcher. I have worked with amazing companies. Nowadays I am working with Cloud base PAAS products. My expertise tech stack JavasScript, Node, Express, Angular, React, Python, Django. Most of my free time I am trying to write blogs to help other developers