Mr_Po,
const users = [{
username: 'David',
status: 'online',
lastActivity: 10,
}, {
username: 'Lucy',
status: 'offline',
lastActivity: 22,
}, {
username: 'Bob',
status: 'online',
lastActivity: 104,
}];
function whoIsOnline(friends) {
let usersOnlineNames = {};
for (let {
username,
status,
lastActivity
} of friends) {
if (status == 'online' && lastActivity > 10) status = 'away';
(usersOnlineNames[status] ??= []).push(username);
}
return usersOnlineNames
}
console.log(whoIsOnline(users))