allArtists = {
let allArtists = {};
usersData.forEach((oneUser, userId) => oneUser.forEach(artist => {
if (artist.fans >= 500000 && !allArtists[artist.id]) {
allArtists[artist.id] = {
name: artist.name,
fans: +artist.fans,
id: artist.id,
genres: artist.genres.split(","),
SharedUserCount: 1,
userIds: [userId]
};
} else if (allArtists[artist.id]) {
if (!allArtists[artist.id].userIds.includes(userId)) {
allArtists[artist.id].SharedUserCount++;
allArtists[artist.id].userIds.push(userId);
}
}
}));
let filteredArtists = {};
for (let artistId in allArtists) {
let artist = allArtists[artistId];
if (artist.SharedUserCount >= SharedFollowers) {
filteredArtists[artistId] = artist;
}
}
return filteredArtists;
};