Tell us what’s happening:
Describe your issue in detail here.
Can someone please explain to me how the function knows that the keys it should be looking for to assign min and max via destructuring are within the stats object? Passing code below under ‘Your code so far’ for reference.
If you had another object that also contained min and max variables, would this confuse the function? As far as I can tell, we are not specifying anywhere within the function that it should be destructuring from the stats object.
Your code so far
const half = ({max, min}) => (max + min) / 2.0;
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;
// Only change code above this line
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/114.0
Challenge: ES6 - Use Destructuring Assignment to Pass an Object as a Function’s Parameters
Link to the challenge: