What is destructuring

Tell us what’s happening:
Describe your issue in detail here.

  **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; 
const half = ({max, min})=> (max+min)/2.0;
Destructured parameter should be used.    what is this error please explain.
// 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/90.0.4430.85 Safari/537.36.

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

Link to the challenge:

Try deleting this comment

1 Like

you’re code looks like it should work so likely an issue with the test

Right. The test is probably reading the comment. That’s why I asked them to try deleting it.

Jeremy is right. Just to expand and explain…

This is the test that is failing:

assert(!code.match(/stats\.max|stats\.min/));

It is confirming that you didn’t use dot notation. It assumes that if you have dot notation in your solution that you may not have used destructuring. At the moment, it doesn’t distinguish between live code and comments.

If I remove that comment, the code passes.

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.