mercredi 5 juin 2019

Return values of an array that are at least 3 times in the array

I'm having trouble making this so I'm asking it here. I have an array like this:

var myArray = ["hi", "hi", "hi", "ha", "ha", "ho", "hu", "hu", "hu"]

What I want is storing the values that occur at least 3 times in a new array. So I should get:

var filteredArray = ["hi", "hu"]

Does anyone know how to do this?

Aucun commentaire:

Enregistrer un commentaire