Help me in taking out unique fruit without reducing it's repeat count ?
I've been trying to arrange this array in an order to take out the same fruit name objects to a seperate array.
I am trying to get something like this :
[{fruit:'apple',id:2},{fruit:'apple',id:6},{fruit:'apple',id:5},{fruit:'apple',id:6},{fruit:'apple',id:9},{fruit:'grape',id:3},{fruit:'grape',id:10},{fruit:'orange',id:4},{fruit:'orange',id:8},{fruit:'banana',id:7},{fruit:'banana',id:11}]
From the array
const arr= [{fruit:'apple',id:2},{fruit:'grape',id:3},{fruit:'orange',id:4},{fruit:'apple',id:5},
{fruit:'apple',id:6},{fruit:'banana',id:7},{fruit:'orange',id:8},
{fruit:'apple',id:9},{fruit:'grape',id:10},{fruit:'banana',id:11}]