Couldn't understand the topic "ES6: Use Destructuring Assignment to Pass an Object as a Function's Parameters"

Tell us what’s happening:
How does the code understand that we want the max and min arguments from the stats objects?AND What if I create another object with same properties max and min?

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 = ({max , min}) => {
       return (max + min )/ 2.0;
} 
// Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0.

Challenge: Use Destructuring Assignment to Pass an Object as a Function’s Parameters

Link to the challenge:

When you call it, you would write:
half(stats);

What if I create another object with same properties max and min?

Then you could use:
half(nameOfAnotherObjekt);

1 Like