Hello everyone
i have this challenge which is require me to `
If there is no one, return “no one online”.
If there 1 person, return “[user1] online”.
If there are 2 people, return [user 1] and [user 2] online".
If there are n>2 people, return the first two names and add “and n-2 more online”.
For example, if there are 5 users, return:
“[user1], [user2] and 3 more online”
`
And This is my code so far
function chatRoomStatus(n,x) {
if (n.length == 0 ) {
return "No one is online"
} else if (n.length === 1) {
return `${n} online`
} else if (n === 2 ) {
return `${n} and ${x} online.`
}
}
console.log(chatRoomStatus([]))
when i left the array empty it returns No one is online
and also when i add one user it returns john online
but when i pass more that one user to the function
its not return it as i wanted it to be