ES6: little help with destructuring

Hi guys!

First time asking for help here. Not sure if this is the way, if it’s not please let me know and sorry in advance.

I have a quick question about an ES6 lesson which I am struggling to understand.

The lesson is:

After almost 25 minutes I managed to find that the solution is:

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

I’m really don’t understand why is this the solution, and why does this half variable understand that max and min are the ones inside the stats variable, as we are not saying that anywhere inside the arrow function. Does this work only for this lesson, because it’s prepared to understand that we refer to the stats variables or am I missing something?

Thanks!!

the half function doesn’t understand that

but if the half function si called as half(stats) or with any other object that have a min and max variable it works like you think

in the editor there is not a function call

Ah jesus thanks, that makes more sense!