Query ! ES6: Use Destructuring Assignment to Pass an Object as a Function's Parameters

How does the args passed in the function detect the object ? what if there was another object with min ,max properties ?

const stats = {

  max: 56.78,

  standard_deviation: 4.34,

  median: 34.54,

  mode: 23.87,

  min: -0.75,

  average: 35.85


// Only change code below this line

const half = ({max,min}) => (max + min) / 2.0; 

// Only change code above this line

The arguments ({max, min}) that you set up in your half function are still argument variables. I can pass any object into the half function and the function will read the min and max properties of that object.

Calling the function half(stats) would perform (56.78 + -0.75) / 2.0.

1 Like