Reduce to One Choice
Reduce to One Choice
reduce can keep the best value seen so far, not only a running total. The accumulator represents the current answer, and each item can replace it when that item is a better fit.
For queue dashboards, a single highest priority value is often enough to decide how urgent the queue is. An explicit starting value gives the function a predictable result when the queue is empty.
Your task: Complete highestTicketPriority so it returns the highest priority value from a ticket list. Return 0 when there are no tickets.
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.
Reduce to One Choice
reduce can keep the best value seen so far, not only a running total. The accumulator represents the current answer, and each item can replace it when that item is a better fit.
For queue dashboards, a single highest priority value is often enough to decide how urgent the queue is. An explicit starting value gives the function a predictable result when the queue is empty.
Your task: Complete highestTicketPriority so it returns the highest priority value from a ticket list. Return 0 when there are no tickets.