*Destructuring Assignment* Doesn't make sense for me

Tell us what’s happening:
I don’t understand how JavaScript know what max and min will be. Because, I can use as many “max” and “min” in others object.

What will happen if I have 3 object, each one with max and min values, how apply destructuring can know what max and min should be choosen?

I hope that you can understand me. Thanks a lot!
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}) => (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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36.

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

Link to the challenge:

only the object that is passed as argument of the half function is destructured, for the stats object it happens when half is called as half(stats)

Hi! thanks for your reply.

I get it! I tried this:

console.log(half(stats));
//Or I  can invoce another object with max and min value
console.log(half(otherObject));

Thank you so much, again!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.