Tell us what’s happening:

This maybe an issue of misunderstanding or a small mistake:

The theory block states the following

const profileUpdate = ({ name, age, nationality, location }) => {
  /* do something with these fields */

with “the do something with these fields” being inside curly braces.
Yet, when I tried to input my answer in a similar way it was not accepted. It worked when I removed the curly braces. Why is it so? Is it a typo in theory?

Thank you

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
// Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Safari/605.1.15.

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

Link to the challenge:

Welcome, mms.

I am not sure what you originally tried, but here is some more examples of valid code, which do the same thing:

const ex1 = ({b, c, d}) => {
  return {b, d}; // Notice the return
const ex2 = ({b, c, d}) => ({b, d}); // Notice: no return, or functional {}

Now, this is not doing the same thing:

const ex1 = ({b, c, d}) => {
  ({b, d}); // Notice: this function does not return anything
const ex2 = ({b, c, d}) =>{ ({b, d}) }; // This function also does not return anything

Here are some lessons to review:

Hope this helps

Hi Sky020!

Thank you for getting back to me so quickly.

I’m still a bit confused, let me try to make my own problem-setting clearer.

The correct answer (or one of the correct answers) to the challenge is the following:

const half = ({max, min}) => (max + min) / 2.0
// the latter part "(max + min) / 2.0 " is not surrounded by curly braces

If I tried to use curly braces like so:
const half = ({max, min}) => {(max + min) / 2.0}

The answer is not accepted, even though the theory is laid out as follows:

const profileUpdate = ({ name, age, nationality, location }) => {
  /* do something with these fields */

Aka, the curly braces are present.
This is what I find to be confusing

Right, I understand the confusion.

The best way to understand it is to run this code, and see the output:

const correctHalf = ({max, min}) => (max + min) / 2.0
const incorrectHalf = ({max, min}) => {(max + min) / 2.0}
const anotherCorrectHalf = ({max, min}) => { return (max+min)/2.0 };

console.log("correctHalf: ", correctHalf({max: 10, min: 2}));
console.log("incorrectHalf: ", incorrectHalf({max: 10, min: 2}));
console.log("anotherCorrectHalf: ", anotherCorrectHalf({max: 10, min: 2}));

I hope there is no typo in there.

Hope this clarifies

So there actually should be a ‘Return’ in the theory bit. Now it makes sense. Thanks a lot!