Why do braces stop my object from deconstructing in this instance

when I am trying to deconstruct this object, the object only deconstructs when I omit the braces, but I don’t understand why.


const stats = {
  max: 56.78,
  standard_deviation: 4.34,
  median: 34.54,
  mode: 23.87,
  min: -0.75,
  average: 35.85

object deconstruction that does not work:
const half = ({max, min}) => {(max+min)/2.0};

object deconstruction that does work:

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

The second is using an implicit return for the arrow function. The first has a function body {} so you have to use an explicit return.

1 Like

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