Eating a whole whale by one bite

Tell us what’s happening:

I can’t grasp a couple concepts on one lesson

Your code so far

//the lesson's code 
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 6

I mean the lesson teaches how to supply out methods with default inputs, can’t it be like

//my code
var increment = (number,value=1)=>number + value;

now it’s painful that I’m googling “how to return a function” and all I get complex things
please we beginners try our best but help us to eat the whale one bite at a time

Your browser information:

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

I can’t link the challenge but you can find it from the below path

You’re right, please just ignore the outer-most function there

It’s an example of an Immediately Invoked Function Expression (IIFE), which you can read about here:

It’s unrelated to the question, probably due to something relating to the tests that run, I’m sure it’ll be changed eventually

1 Like

It has already been changed in our master branch, but not yet rolled out to production. The current production uses the IIFEs for testing purposes. We have removed them from 7 challenges which were using them strictly for testing purposes.

1 Like