0

how can I change the following to ternary so I can use it in .HTML file

if (statusChange && statusChange === 'Employed') {
  return true;
} else {
  return employmentStatus === 'Employed'
}

i.e. assign the result of the second comparison only if the first if statement results to false

2 Answers 2

2

No need for ternary operation here, just use the or operation:

statusChange === 'Employed' || employmentStatus === 'Employed'

If the first part is true, the whole expression will return true. If it's false, it will check it the second part is true or false

Much cleaner

Sign up to request clarification or add additional context in comments.

1 Comment

much cleaner indeed. thanks for answering
1

Simply:

return statusChange && statusChange === 'Employed' ? true : employmentStatus === 'Employed'

1 Comment

Note that this expression has the same result as statusChange === 'Employed' || employmentStatus === 'Employed'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.