A simple way to determine the replacement string is that there seems to be nothing wrong with it, so that if the state is empty or the default is "online", the result is that "online" is still output when the state is "offline".
var state = optionsEntity.state; //state"offline"
var states = function(state){
return state == "" ? "online" : (state=state||"online");
};
console.log(states()); //"online"
is it because of such a nested error in ternary?