The message value does not end as "success" , but "success" .
The operator ? has a lower priority than the || , so the code evaluates to:
message = (message || type == 'success') ? 'Success' : 'Error';
Result message || type == 'success' message || type == 'success' will be "Thank You" , and if it is evaluated as logical for the statement ? , the result will be true .
Guffa source share