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

Tell us what’s happening:
Describe your issue in detail here.
I tried lots of time to do this task[ half(stats) should be28.015 ]but i could do it
I don’t know what should I do.
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;
 half(stats) ;
}

 

// 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/110.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 a stray curly bracket. If you remove it your code will pass.

I’m possibly being dense but I don’t actually understand why the code wouldn’t pass if you had a pair of curly brackets around the function code.

Why doesn’t this code pass (returns undefined)? (But it does if you remove the second pair of curly brackets).

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

it is asking me to make half(stats) to be 28.015

Implicit vs explicit return statements

Oh yeah, of course. Silly me.

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