Let's say I have an array that looks like this:
arr = [25, 25, 25, 20, 15, 10, 10, 5];
My goal is to count the number of duplicate values (for example, three 25s and two 10s) and create a new array that would look like this:
newArr = ['25 * 3', 20, 15, '10 * 2', 5];
What would be the most effective way to achieve this task? Your guidance is much appreciated!