Givan an object of users. Each user can belong to one group or more.
const users = {
1: {
id: 1,
email: '[email protected]',
teams: []
},
2: {
id: 2,
email: '[email protected]',
teams: [1,2]
},
3: {
id: 3,
email: '[email protected]',
teams: [2,4]
},
4: {
id: 4,
email: '[email protected]',
teams: [1,5]
},
}
const msg = {
text: "Hi",
sender: 2,
mentions: {
users: [1,3],
groups: [3,4]
}
}
function sendNotification(text, email) {
console.log(`send email to ${email}`);
}
Write a function that calls sendNotification
fucntion in order to send a message to all the users and the teams mentioned in the msg.mentions
object. You can’t change anything in the given users
object and the sendNotification
functions.
function x(msg) {
// implement your code here.
}
4