input: arbitrary array
output: unique elements and their count
So far I was able to find the unique elements but I can't figure it out how to correlate them with the count for each element. Any suggestions(without using functions if possible - just started and didn't get to functions yet)?
var arr = [3, 4, 4, 3, 3];
var new_arr = [];
for (i = 0; i < arr.length; i++) {
if (new_arr.includes(arr[i])) {
// pass
} else {
new_arr.push(arr[i]);
}
}
console.log(new_arr);