ES6 - Use Destructuring Assignment to Pass an Object as a Function's Parameters

Tell us what’s happening:
My code works, but I don’t understand why as I can’t figure out what links const half to the stats object. I’m guessing that something is happening during the test, but I can’t figure out what. Is it that they are setting a variable with a line like this?


Your code so far
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 = (stats) => (stats.max + stats.min) / 2.0;
const half = ({max, min}) => (max + min) / 2.0;
// Only change code above this line

The stats global object already exists in the code. One of the tests just calls the half function with stats as the argument.


Got it, THANKS!
I get what is happening now.