I have been given a task at my internship , I have to create math operations like plus(), minus() etc. using this and new keywords.
example:- one().plus().two().equalTo() , given line of code must return 3.
I tried creating functions which returns values.
function one(){ return 1; }
.
But I am not able to figureout how plus() and equalto() will work.
2
Answers
Sorry I edited this answer . I have misunderstood the question . I think this is what you are looking for right ? So for starter you can do something like this
to make it more dynamic you can use for loop and create a wrapper of those number
for e.g 100’s of them
Here’s a solution using function chaining: