Hello,
I am having trouble understanding how the function’s parameters reference the object’s min and max.
When we access an object’s values, we have done it like this
const user = { name: 'John Doe', age: 34};
const {name, age} = user;
So I see that the deconstruction format is similar to what’s inside the function’s parameter but the function for this challenge simply puts the parameters of the object’s key it wishes to target.
This is how I would have expected the code to be just so you know what I’m thinking
const half = ({ max, min } = stats) => (max + min) / 2.0;
or something similar to this. I know that in the console.log we pass in the object stats
but I would expect this to result
const half = ( stats {max, min} ) => (max+min) / 2.0;
**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
console.log(half(stats))
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36 Edg/94.0.992.50
Challenge: Use Destructuring Assignment to Pass an Object as a Function’s Parameters
Link to the challenge: