Given an arbitrary array, the goal is to determine the unique elements in the array along with their respective count. While I have managed to identify the unique elements within the array, I am struggling to establish a way to associate each element with its count. Any suggestions on how to achieve this without utilizing functions? I am new and haven't delved into 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);