Well, we are talking about a Javascript feature here!

Intro picture
Write a function that will increment counter by one and when it is called again it will be incremented againfunction outer(){
let counter = 0; //backpack analogy
function increment(){
let num = 1
counter = counter + num
return counter
}
return increment; //function declaration not invocation
}
let innerFunc = outer()
console.log(innerFunc())//1
console.log(innerFunc())//2
console.log(innerFunc())//3
function increment(){
let counter = 0
let num = 1
counter = counter + num
return counter
}
console.log(increment());// 1
console.log(increment());// 1
console.log(increment());// 1
Write a function that we can only call ONCE, if you run it first time it will print the timestamp with the label first run ,
if you try run it again it should not do anyting.

Software Engineer Apprentice at IBM