Skip to content
Advertisement

frequency of each element in array

I tried to delete the duplicate value and print the count of each element. But I didn’t get the correct answer. How to delete only the duplicate value and print the count? Here is my code

JavaScript

I need output as

JavaScript

Advertisement

Answer

The problem is that you are removing an element and not updating j accoridngly.

To fix your code, try this:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement