In the challenge “ES6: Use Destructuring Assignment to Pass an Object as a Function’s ParametersPassed”, we don’t even put the name of the const ‘stats’ anywhere in the code.
But the computer still knows we are referring to ‘stats’.
Is it because ‘stats’ is the only object found in the code?
What if there is another object called ‘statsYesterday’ with the same properties in it (max, min, mode, median…etc)?
Will the destructuring assignment still work?
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 = (stats) => (stats.max + stats.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: