Tell us what’s happening: My answer accepted for this challenge is a lot simpler than the expected answer on the solutions page. Can anyone think why my answer wouldn’t be the desired answer???
All answers welcome, thank you!
Your code so far
function increment(num1, value=1) {
return num1 + value;
};
console.log(increment(5, 2)); // returns 7
console.log(increment(5)); // returns 6
Solution From Get A Hint Page
const increment = (function() {
"use strict";
return function increment(number, value = 1) {
return number + value;
};
})();
console.log(increment(5, 2)); // returns 7
console.log(increment(5)); // returns NaN
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions