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;
// 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/108.0.0.0 YaBrowser/23.1.1.1138 Yowser/2.5 Safari/537.36
Challenge: ES6 - Use Destructuring Assignment to Pass an Object as a Function’s Parameters
Link to the challenge:
On this site, there is no explanation on this topic on programming, or does it depend on the code?
No, because it is not clear why it is needed and where it should be applied, and how to understand it? Here on the forum everyone wants specifics, but how to specifically explain, if it is not clear from the material presented, you have a very strange position here.
These challenges appear to cover this concept fairly thoroughly, though sometimes there can be sticking points…
Can you explain exactly what it is that you’re struggling to get your head around? It’s not uncommon to get stuck on certain programming concepts… I struggled with recursion for a few days for instance.
Another good approach is to find other articles which may explain it in a different way:
There isn’t just one use or reason for using destructuring.
It is a convenient syntax and using it can also improve code readability. You use the syntax because it is useful. It is used a lot in JS code so it is obviously useful syntax, even if you do not yet see it. You need to use it to see its usefulness.
It is like asking why you would use forEach when we already have normal for loops. You use a forEach because it is less error-prone and gives cleaner code, not because you can’t do the same thing using a for loop.