Tell us what’s happening:
Describe your issue in detail here.
How does Javascript know the object I want to destructure without me specifying it? I don’t understand this.
the solution was said to be :
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 = ({ max, min }) => (max + min) / 2.0;
// Only change code above this line
But, I have no idea how you can just write max, min, etc and javascript pulls it from the Stats object?
if I have two objects, or four, or five. And say I have two objects that both have a min / max key in them. How would javascript know / understand or attempt to pull from the stats object for the destructuring? And why / how does it work? I failed this and had to search for the answer because I’m trying to use “stats” specifically somewhere in order to de-structure, and I can’t understand why you don’t have to use it. Can anyone provide some clarity on this?
Link to the challenge: