Its official that I am spinning my wheels on this one. I must Use destructuring assignment within the argument to the function half to send only max and min inside the function.
stats should be an object .
half(stats) should be 28.015
Destructuring should be used.
Destructured parameter should be used.
const stats = {
max: 56.78,
standard_deviation: 4.34,
median: 34.54,
mode: 23.87,
min: -0.75,
average: 35.85
};
// i tried writing the answer below a few different ways but honestly this one is //confusing me and i know my answer may not even be close.
const half = (stats) => {
(stats.max + stats.min) / 2.0};
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36
Challenge: Use Destructuring Assignment to Pass an Object as a Function’s Parameters
destructuring allows you to assign values to variables from an object
for example, you could do
const {max, min} = stats;
and the two variables will have the values of the properties of the same name from the object
in place destructuring put the assignment of a value passed in to the function to a parameter together with this
passing a value to a function is pretty much the same as assigning the value passed in to a function to the parameter using the assignment operator parameter = argument
if the parameter isn’t a single variable, but destructuring syntax, it works the same
so
function example ({var1, var2}) {}
when example is called as example(argument) it happens pretty much {val1, val2} = argument