Hi all - for the life of me, I can’t figure out what’s wrong here. I pass the result test and the use of deconstruction test, but it fails on “Deconstructed parameter must be used.” Isn’t the return line (max + min) / 2.0;
using the deconstructed parameter? Aren’t min
and max
the deconstructed parameters?
I have looked at past questions on this problem but they all seem to pre-date integration of the arrow syntax. Any use of the function()
syntax now, or that still has the word stats
in it, fails both deconstruction tests. (At least any of the four hours’ worth of combinations I have tried). So does assigning the deconstructed parameters to new variables and using those. I’m out of ideas. Any thoughts?
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 = ({ max, min }) => (max + min) / 2.0;
//ORIGINAL: 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 6.3; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0
.
Challenge: Use Destructuring Assignment to Pass an Object as a Function’s Parameters
Link to the challenge: