Hello i need some help, i cant understand what to do, and how!

Tell us what’s happening:

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 = (stats) => (stats.max + stats.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/85.0.4183.121 Safari/537.36.

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

Link to the challenge:

Hey there. In the explanation we’re shown how to destructure an object

const profileUpdate = (profileData) => {
  const { name, age, nationality, location } = profileData;
  // do something with these variables

 // my own addition to the example
  console.log(name)
}

In this case to log out the name we didnt have to access it in this way: profileData.name or profileData[name]
This is because we destructured it here

const { name, age, nationality, location } = profileData;

In this challenge we learn that it is possible to destructure the whole object in the parameters during the function definition then it will work when we pass in the object during the function call
so to log out the name using destructuring:

const profileUpdate = ({ name }) => {
  /* do something with these fields */
  console.log(name)
}

profileUpdate(profileData)

This is what they want you to do in this challenge. I hope this helped. Goodluck!

thank you , i think i get it!

1 Like