HI All,
So I was able to solve this challenge, and I think I did so in the way intended (my code is below), but I am a little confused by this particular example. My confusion is about why using destructuring would be preferable in this scenario. It seems to me like you could just pass the stats object as the argument to the half function the return line (stats.max + stats.min) / 2.0 would still work fine. Is this just the exercise introducing the concept or is there some benefit to using the deconstruring assignment here?
Thanks in advance!
const stats = {
max: 56.78,
standard_deviation: 4.34,
median: 34.54,
mode: 23.87,
min: -0.75,
average: 35.85
};
const half = (function() {
“use strict”; // do not change this line
// change code below this line
return function half({max, min}) {
return (stats.max + stats.min) / 2.0;
};
// change code above this line
})();
console.log(stats); // should be object
console.log(half(stats)); // should be 28.015