Higher Order Functions

Chain Selection Before Ordering

Chain Selection Before Ordering

A chain can express a small reporting pipeline: choose the records that matter, order that subset, and transform it into the final shape. The source array should remain stable unless the task specifically asks for mutation.

sort is the risky step because it mutates the array it runs on. Filtering first creates a new array, but later readers should still be able to trust the original member order. A copied sort keeps the pipeline result separate from source state.

Your task: Complete recentActiveEmails so it returns the emails of active members ordered by lastSeen from newest to oldest. Do not mutate the original member array.

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.

Chain Selection Before Ordering

A chain can express a small reporting pipeline: choose the records that matter, order that subset, and transform it into the final shape. The source array should remain stable unless the task specifically asks for mutation.

sort is the risky step because it mutates the array it runs on. Filtering first creates a new array, but later readers should still be able to trust the original member order. A copied sort keeps the pipeline result separate from source state.

Your task: Complete recentActiveEmails so it returns the emails of active members ordered by lastSeen from newest to oldest. Do not mutate the original member array.

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.