The example provided for this challenge are misleading

Tell us what’s happening:
Describe your issue in detail here.

  **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;

// Only change code above this line

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

Link to the challenge:

My above code is the solution to this challenge. When reading the material and examples provided for this challenge, the syntax was provided as such:

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

}

To solve this challenge, I had mimic’d the syntax of this example which looked like this:

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

This lead me to about an hour of frustration trying to figure out what was wrong with the code, considering it appeared correct according to the example. I’m just bringing it to the attention of others with my same problem, I’m not sure if the brackets were used as a placeholder for “your code goes here” or if the example is written incorrectly.

Arrow functions were described here:

You can use the {}s or not with arrow functions depending upon what the body is.

In this case, you can use a function body with {}s so long as you also use a return statement.

1 Like

When a function block is defined by curly braces, you need a return statement in order to return anything. The difference was described in Use Arrow Functions to Write Concise Anonymous Functions

1 Like

A small detail I overlooked. Now I know, thanks!