Could anyone tell me how this whole code works ,the nested increment function is all i understand , but is const increment = (function()… a function ? I don’t really understand the syntax of how it is working , and how is console.log accessing the parameters .JUST EXPLAIN THE WHOLE THING , I AM CONFUSED
Your code so far
const increment = (function() {
"use strict";
return function increment(number, value) {
return number + value;
};
})();
console.log(increment(5, 2)); // returns 7
console.log(increment(5)); // returns NaN
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions