Higher Order Functions

find Returns One Item

find Returns One Item

find searches an array and returns the first item whose callback passes. It stops once it has that item.

The result is one item or undefined, not an array. That makes find useful for selecting one record, such as the first blocked step or the user with a matching id.

Your task: Use find to create firstBlockedStep from steps. It should hold the first step whose blocked property is true.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

find Returns One Item

find searches an array and returns the first item whose callback passes. It stops once it has that item.

The result is one item or undefined, not an array. That makes find useful for selecting one record, such as the first blocked step or the user with a matching id.

Your task: Use find to create firstBlockedStep from steps. It should hold the first step whose blocked property is true.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Console

Run code to see output.