The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Use Some as a Ternary Operator or Conditional

Use Some as a Ternary Operator or Conditional

5:43
`some` returns a `boolean` value after passing each item in the source array through the test function that you pass in as the first parameter. This makes it well suited to the types of queries that require a simple `yes` or `no` answer. In this lesson we look at 2 practical use-cases for `some`. The first shows how it can be used with a ternary operator to switch a `class` on an element & the second shows how `some` can be used in an `if` conditional.
Watch this lesson now
Avatar
egghead.io

some returns a boolean value after passing each item in the source array through the test function that you pass in as the first parameter. This makes it well suited to the types of queries that require a simple yes or no answer. In this lesson we look at 2 practical use-cases for some. The first shows how it can be used with a ternary operator to switch a class on an element & the second shows how some can be used in an if conditional.

Avatar
Shane Unger

I understand how some is working here, but It seems to me like the same thing could be accomplished just as easily with a map that has a conditional check. Is there a benefit I'm not seeing to using some instead?

In reply to egghead.io
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?