vendredi 23 septembre 2016

How to get correct answer

I have this example, how i can make it to show the correct answer. If one the status is online, the global status is online. If some one is away, global status is away. If offline -> offline.

var group, part1, part2, part3;

group = 'Group Status';
part1 = 'online';
part2 = 'away';
part3 = 'offline';

if( part1 === 'online' || part2 === 'online' || part3 === 'online' ){
    group = 'Online';
    console.log('All users are online. Group status: ' + group);
}else if( part1 === 'away' || part2 === 'away' || part3 === 'away' ){
    group = 'Away';
    console.log('One of the users is away. Group status: ' + group);
}else if( part1 === 'offline' || part2 === 'offline' || part3 === 'offline' ){
    group = 'Offline';
    console.log('One of the users is offline. Group status: ' + group);
}else{
    group = 'Not found';
    console.log('Status not found. Group status: ' + group);
}

Aucun commentaire:

Enregistrer un commentaire