How does the program know the properties are from that specific object?

Tell us what’s happening:
How does the program know that max and min are from the stats object? What if there was another object with max and min properties?

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; 
// Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36.

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

Link to the challenge:

You’ve to pass a particular object while using half, in this case stats can be passed. That’s how it’ll know that min and max are from stats.

1 Like

Sorry I was Totally wrong
please disregard these ramlings

it does not and you have not passed an object to any thing
this is an error
({max, min}) => (max + min) / 2;
and even if it was correctly written
min and max would still be undefined
objects are written more like this …
Sorry I was Totally wrong
please disregard these ramlings

maybe moderators will clean up this mess

this is a totally correct way of writing a function

it’s an arrow function plus object destructuring in place

@piedcipher’s answer is correct


Thank you! I get it now

1 Like