Coolblue interview question

Complete a function to generate the expected outcome (functional programming using reduce() and other JS functions)