Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
Using Destructuring Assignment to Pass an Object as a Function’s Parameters

freeCodeCamp has a lesson titled “Use Destructuring Assignment to Pass an Object as a Function’s Parameters”. In that lesson they provide the following code:

const profileUpdate = (profileData) => { 
Const {name, age, nationality, location} = profileData; 
    
// will refer to this code block as A 

They then go on to state: “This effectively destructures the object sent into the function”.

From what I understand, in A) profileUpdate is the function identifier and profileData is the function parameter. In this case, any argument that the function profileUpdate would accept would ostensibly have to be an object with the property identifiers of name, age, nationality and location given the second line of the code up above. After receiving just an object, profileUpdate would respectively create variables of name, age, nationality and location and assign them the value of respectively, profileData.name, profileData.age, profileData.nationality and profileData.location. Again, I believe this to be correct but if I have misunderstood anything please feel free to correct me. // will refer to this paragraph as C.

Now, freeCodeCamp splits their webpage in half. On the left side of the page is the lesson and on the right side of the page is a problem to test your comprehension of the lesson. On the left side of the page they gave us the following object:

const stats = { 
    
  max: 56.78, 
  standard_deviation: 4.34, 
  median: 35.54, 
  mode: 23.87, 
  min: -0.75, 
  average: 35.85 
};


// will refer to this object as B 

So i decided to take the general structure of A and apply it to B to verify that I truly understood A. I wrote the following in VScode:

const stats = {
  
  max: 56.78,
  standard_deviation: 4.34,
  median: 34.54,
  mode: 23.87,
  min: -0.75,
  average: 35.85

};


 const statsUpdate = (x) => {

  const {max} = x;

 }

statsUpdate(stats); 

console.log(max); 
console.log(typeof max); 

expecting the values of 56.78 and object to appear but instead I get a reference error stating “max is not defined”. I’m clearly not understanding something in paragraph C up above or I am not writing the right expressions in the code immediately up above. What am I doing wrong? I have tried to see the error but I’m not capable of seeing it right now and your help would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!