Looking at the task ahead,
let increment = new Increment();
I have been tasked with creating a Javascript class or function called Increment
in order to achieve the following:
console.log(`${increment}`)
// should output 1
console.log(`${increment}`)
; // should output 2
console.log(`${increment}`)
; // should output 3
console.log(`${increment}`)
; // should output 4
The key here is that increment
cannot be a function, meaning I cannot use increment()
, nor can it be a property like increment.count
.
Therefore, the challenge boils down to the following code snippet:
let increment = new Increment();
console.log(`${increment}`); //1
console.log(`${increment}`); //2
console.log(`${increment}`); //3
console.log(`${increment}`); //4
My goal is to craft a function named Increment
that will give me the desired sequential output.