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);
- [Vuejs]-How to change the style of layout elements for each specific page?
- [Vuejs]-Vue.JS: Communication with component
Source:stackexchange.com