[Vuejs]-Extract an elelment's property without repetitions from an array of objects, obtained from an API, in Vue 2

0👍

Your filter function is not correct. the element.genre != element.genre condition is always false because it is comparing the same element to itself each time.

you can do something like this:

if (this.cds.length == 10) {
    const genres = {};
    this.cds.forEach((element) => {
       if(!genres[element.genre]) {
          genres[element.genre] = element;
       }
    });
}
this.genreArray = Object.values(genres);

Leave a comment