My approach would be to push the results into an array, only if that category doesn't already exist in the array (you can check by using array.indexof(category). If it does exist then add one to that index instead.
Alternatively, you can check if only the last entry was the same, by comparing either the front or back of the array (whichever one you push to), to your current input. If it is the same, increment, and if it is different, push a new cell.