Menu
Coddy logo textTech

Recap - The Chain Master

Part of the Logic & Flow section of Coddy's JavaScript journey — lesson 59 of 65.

challenge icon

Challenge

Easy

Create a function called chainMaster that takes an array of numbers as an argument. The function should use chained array methods to perform the following operations:

  1. Keep only numbers that are divisible by 3
  2. Multiply each remaining number by 2
  3. Sort the resulting array in descending order
  4. Return an object with the following properties:
    • transformedArray: The final array after all operations
    • sum: The sum of all numbers in the final array
    • average: The average of all numbers in the final array, rounded to two decimal places

Use appropriate array methods (filter, map, sort, reduce) in your solution.

Try it yourself

function chainMaster(numbers) {
    // Write your code here
  
  
  
    return {
        transformedArray: result,
        sum: sum,
        average: average
    };
}

All lessons in Logic & Flow