# Can somebody help me ! :((

Tell us what’s happening:

``````
const stats = {
max: 56.78,
standard_deviation: 4.34,
median: 34.54,
mode: 23.87,
min: -0.75,
average: 35.85
};

// use function argument destructuring
// change code below this line

/*
const half = (function(){
"use strict";
return (({max,min})=>{
return (max+min)/2.0;
});
})();
*/

const half  = (function() {

return function half({max,min})
{
return (max+min)/2.0;
};
})();

// change code above this line

console.log(stats); // should be object
console.log(half(stats)); // should be 28.015

``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) coc_coc_browser/80.0.180 Chrome/74.0.3729.180 Safari/537.36`.

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

So the original was a function that looked something like this:

``````const half = (stats) => (stats.max + stats.min) / 2.0;
``````

So `half` is a variable that holds a function. That function takes a parameter, `stats`, and calculates the mid-point. The purpose of the lesson was to remove the word `stats` from the formula, and instead use object deconstruction in the parameter, thus having two variables, `min` and `max`, which are equal to the primitive values stored inside `stats`.

In your code, you have a function `half` that is the result of an IFFE, creating a closure around… well, not much. You create the closure, and return the function itself to half, rather than simply changing the parameters to the given function.

Your code does return the proper result. But the closure is interfering with the test, because it’s giving considerably more than the test actually wanted. Your code is not giving a wrong answer to the `half` question, simply a wrong answer to the lesson itself.

Remove the IIFE, and simply use destructuring on the function originally being assigned to `half`. Basically, remove the wrapping IIFE, and you should pass fine.

1 Like

I’m thanks very much :(( I understood