14

In CoffeeScript, is there a way to simplify the following:

if(value === "something" || value === "else" || value === "wow"){}

I've tried:

if value is "something" or "else" or "wow"

But this produces the literal output of this:

if(value === "something" || "else" || "wow){}

Is there a way to check if a string is one of multiple values (OR or AND) in CoffeeScript?

1 Answer 1

29

I think you probably want

if value in ['something', 'else', 'wow']
Sign up to request clarification or add additional context in comments.

Comments

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.