Hi guys, my code works but I don’t really understand how.
const half = ({max, min}) => {
return (max + min) / 2.0;
}
I don’t see where I can specify the object I want to destruct and get its {max, min} as the parameters. What’s gonna happen, or which object will be destructed, if there were 2 or more objects above?
Thanks!
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
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36
Challenge: ES6 - Use Destructuring Assignment to Pass an Object as a Function’s Parameters
Thank you ilenia!
What baffles me is that, when I passed {max, min} to the half function(as in my code), I didn’t specify {max, min } of which object I was passing (or did I)?
If there were 2 objects above, stats1 & stats2, both containing properties MAX & MIN, which object will be passed, when only {max, min} is given as parameter?
Just to be clear, the test will call the function for you and passes in the object stats as the argument. You can tell which function calls will happen by looking at the tests.