I have this code:
var newStatus = (status, subStatus) => {
if(status === 'CREATED' &&
(subStatus === 'subStatus1' || 'subStatus2' || 'subStatus3')){
return 'CONFIRMED';
} else if(status === 'CANCELLED' &&
(subStatus === 'subStatus4' || 'subStatus5' || 'subStatus6')){
return 'REMOVED';
} else if(status === 'REVIEW' &&
(subStatus === 'subStatus7' || 'subStatus8' || 'subStatus9')){
return 'CHECKED';
}
}
<div>newStatus('CREATED', 'subStatus2')</div>
In this case, the div must render with the value 'CONFIRMED'. I believe this logic has a bug and I need 'subStatus ' to be an array and check somehow against each element, but how can I achieve this?
Can someone help me with a solution on how to implement this logic correctly?