Below is my solution to the challenge and the error messages
My 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 = ({max, min} = stats) => (max + min) / 2.0;
// Only change code above this line

Challenge: Use Destructuring Assignment to Pass an Object as a Function’s Parameters
Link to the challenge:
Besides the checker being precise or not, it is identifying this line does not exist:
(stats.max + stats.min)
You can write stats1 + stats2,
or whatever, but not dot notation.
To me, that’s reasonable, you’re using destructuring and avoiding dot notation.
Also, this way it helps people using destructuring in the function, but forgetting to remove the dot notation in function’s body.
1 Like
oh I see, that’s helpful. But on the down side it restricts how creative solutions can be…I guess
Thanks
1 Like
Yes, that’s probably true, but at the same time, you can check your output console.logging anything, and shouldn’t worry much about the result.
At least, on my own experience (i’ve never finish the courses) you learn a lot just by playing with the code.
eoja
5
Behind the scenes the test calls half(stats)
.
So in your function to access max and min you only need ({min, max})
rather than ({max, min} = stats)
.
2 Likes