Tell us what’s happening:
I think the challenge answer may be wrong. It claims the answer should be 28.015 with values of max: 56.78 and min: -0.75. stat.max + stat. min = 56.03 not 28.015. There may be something wrong with my code, and if there is please let me know, but I ran this in Visual Studio Code and got the correct answers.
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
};
const half = (function() {
"use strict"; // do not change this line
// change code below this line
return function half(stats) {
const {max, min}=stats; // use function argument destructuring
return (stats.max + stats.min);
};
// change code above this line
})();
console.log(stats); // should be object
console.log(half(stats)); // should be 28.015
FREECODECAMP ERROR
// running tests
half(stats) should be 28.015
Destructuring was used.
// tests completed
VISUAL STUDIO CODE RESULT
{ max: 56.78,
standard_deviation: 4.34,
median: 34.54,
mode: 23.87,
min: -0.75,
average: 35.85 }
56.03
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters