Destructuring Assignment to Pass an Object as a Function's Parameters

Destructuring Assignment to Pass an Object as a Function's Parameters


Tell us what’s happening:
this is more a question on why the description of the challenge was written the way it was.

both examples of code given:
const profileUpdate = (profileData) => {
_ const { name, age, nationality, location } = profileData;_
_ // do something with these variables_
_ }_

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

involve => style syntax, which you can’t use to solve the problem. Shouldn’t the examples involve the syntax we are supposed to be learning? In this case how to pass only the pertinent parts of an object to a particular function. my code works, but getting to it involved google, reading the description didn’t help much.

if I’m mistaken and there is a way to write this using =>, please let me know. thanks!
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
const half = (function() {
  "use strict"; // do not change this line

  // change code below this line
 return function half({max, min}) {
    // use function argument destructuring
    return (max+ min) /2;
  // change code above this line

console.log(stats); // should be object
console.log(half(stats)); // should be 28.015

//const {tomorrow : {max: maxOfTomorrow}} = forecast;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0.

Link to the challenge:


The curriculum lessons and challenges were written under the idea that you first read the instructions and try to create a solution. If that is not enough, you search (i.e. search engine, forum search feature, etc…) for how to accomplish the task, and last you ask (i.e. posting a question on the forum). It is not meant to be a comprehensive curriculum. You will notice in the first HTML and CSS exercises, you were basically told exactly what to do to solve the challenge. As you move farther along in the curriculum, it is expected for you to sometimes go beyond the Free Code Camp instructions and Guides and search on the web for ideas about how to solve the challenges.

That being said, if you feel a lesson or challenge could benefit from a word change of some sort, you can always open an issue on github with your suggestion and see if it gets implemented into the curriculum.


fair enough, thanks for the response.