Use Destructuring Assignment to Pass an Object as a Function& Parameters

Tell us what’s happening:
Hi guys,this code works just fine but the thing is when i write it in VS it sends me a message that All destructured elements are unused.though the result is correct.Can anyone tell me what’s wrong with my code ?

Your code so far


  "use strict";
const stats = {
  max: 56.78,
  standard_deviation: 4.34,
  median: 34.54,
  mode: 23.87,
  min: -0.75,
  average: 35.85
};
const half = ({max,min}) =>{
  
    return (stats.max + stats.min) / 2.0;
  };
 
  
  


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

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters/

i only did it because though i could solve the challenge,i never did understand this part :
const half = (function() {
“use strict”; // do not change this line

// change code below this line
return function half(stats) {
// use function argument destructuring
return (stats.max + stats.min) / 2.0;
};
// change code above this line

})();

note:anyone can understand what this code aims to do,i just don’t understand the syntax of so many functions and ()s

You were not supposed to worry about the part outside of the inner function. That was for the tests behind the scenes. You will learn more about that other syntax later in the curriculum. For now, see if you can solve the challenge by only changing the inner function’s code.

well it was pretty easy solving the challenge as asked,i just tried very hard to understand the whole syntax .Didn’t know i wasn’t supposed to understand it at this level.Thanx