Arrow syntax curly braces

Tell us what’s happening:
I had most of the solution, but I added curly braces AFTER the => and the tests failed. Can someone explain what the extra braces are doing that fails the test?

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 = ({min, max}) => { (max + 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/87.0.4280.88 Safari/537.36.

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

Link to the challenge:

You are returning undefined

Without the curly braces, there’s an implicit return. But with the curly braces there’s no such implicit return statement for you

So, you have to explicitly state your return with curly braces

3 Likes

In other words, when it’s a single expression, just drop the curlies entirely.