ES6 - Use Destructuring Assignment to Pass an Object as a Function's Parameters

Tell us what’s happening:
where, I should remove stats & use destructured parameter??
I’ve tried every possible way…
can you eloborate this
I didn’t get this destructuring object in function argument itself
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 = (stats) => (stats.max + stats.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/109.0.0.0 Safari/537.36

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

Link to the challenge:

you have to use destructuring for this exercise.
So your half function should take the input param and destructure it as per the example in the exercise.

The example given was this:

const profileUpdate = ({ name, age, nationality, location }) => {

}

So there they destructured an input param into its 4 parts

In your case the input param is stats. You will need to destructure it to get the parts that you need (max and min) out in order to get the average.

hint: the answer does not involve the word stats anywhere

const half = ({max} + {min} / 2.0) => {

};
I’ve tried it as the example appears
it’s not working out!!
how to perform the operation within the function??

the syntax is wrong here:

this is the part that is supposed to do the destructuring, not the division.

Compare it to the example:

1 Like

oh, okay
Got it!!
Thank you

1 Like

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