# Day 8 30 Days of Leetcode Challange

## 2667. Create Hello World Function

``````/**
* @return {Function}
*/
var createHelloWorld = function() {

return function(...args) {
return "Hello World"
}
};

/**
* const f = createHelloWorld();
* f(); // "Hello World"
*/
``````

## 2620. Counter

``````/**
* @param {number} n
* @return {Function} counter
*/
var createCounter = function(n) {

return function() {
return n++
};
};

/**
* const counter = createCounter(10)
* counter() // 10
* counter() // 11
* counter() // 12
*/
``````

## 2704. To Be Or Not To Be

``````/**
* @param {string} val
* @return {Object}
*/
var expect = function(val) {

return{
toBe:(data)=>{
if(val===data) return true
else throw new Error("Not Equal")
},

notToBe:(data)=>{
if(val !== data) return true
else throw new  Error("Equal")
}
}

};

/**
* expect(5).toBe(5); // true
* expect(5).notToBe(5); // throws "Equal"
*/
``````

## 2665. Counter II

``````/**
* @param {integer} init
* @return { increment: Function, decrement: Function, reset: Function }
*/
var createCounter = function(init) {
let currentcount = init
return{
increment:()=>{
return ++currentcount
},
reset:()=>{
return currentcount = init
},
decrement:()=>{
return --currentcount
}
}
};

/**
* const counter = createCounter(5)
* counter.increment(); // 6
* counter.reset(); // 5
* counter.decrement(); // 4
*/
``````