Not 100% Clear: Use Destructuring Assignment to Pass an Object as a Function's Parameters

Tell us what’s happening:

I think this lesson should be overhauled because as it is right now there is no way for the user to know how the computer knows where to take the max and the min property from.
Obviously if I run the function and put in a specific object (e.g. console.log(half(stats)); ) this becomes much clearer but in the lesson as is the user (and I) will be puzzled because the connection that the function will be called with an object instead of just {max,min} is not obvious at that state learning JS.

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; 
// Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36.

Challenge: Use Destructuring Assignment to Pass an Object as a Function’s Parameters

Link to the challenge:

2 Likes

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

1 Like