Hi,
const stats = {
max: 56.78,
standard_deviation: 4.34,
median: 34.54,
mode: 23.87,
min: -0.75,
average: 35.85
};
//code 1:
const half = (function() {
“use strict”;
return function one({max,min}) {
// use function argument destructuring
return (max + min) / 2.0;
};
// change code above this line
})();
//code2:
const half = function(two){
function one(tw){
return (tw.max + tw.min) / 2.0;
}
return one(two);
};
console.log(stats); // should be object
console.log(half(stats)); // should be 28.015
In code 1 the half = (function() {})(); //No argument for receiving half(stats) when passed
In code 2 hald = function(two){}; //has arg two for receiving half(stats) when passed
Both codes are working,but how the code 1 works without argument?