Q:

How to get correct answer

I have this example, how i can make it to show the correct answer.
If everyone is online, then the global status is online.
If some one is away, global status is away.
If everyone is 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);
}

Answer: the priority of this code is Online > Away > Offline.
I replaced and it worked as i want: Offline > Away > Online.
var group, part1, part2, part3;
group = 'Group Status';
part1 = 'online';
part2 = 'away';
part3 = 'away';

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

A:

You could move all parts into an array and check with Array#some and Array#every for the wanted status.

var group = 'Group Status',
    parts = ['online', 'away', 'offline'];

if (parts.some(function (a) { return a === 'offline'; })) {
    group = 'Offline';
    console.log('One of the users is offline. Group status: ' + group);
} else if (parts.some(function (a) { return a === 'away'; })) {
    group = 'Away';
    console.log('One of the users is away. Group status: ' + group);
} else if (parts.every(function (a) { return a === 'online'; })) {
    group = 'Online';
    console.log('All users are online. Group status: ' + group);
} else {
    group = 'Not found';
    console.log('Status not found. Group status: ' + group);
}

ES6

var group = 'Group Status',
    parts = ['online', 'away', 'offline'],
    check = string => item => item === string;

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

