How to create a function calculator? [Programming Interview Question]
@Yomesh Gupta

Create a function calculator that should take one initial value. Chain calulations like add, subtract on it. It shoudl return the calculated value on invocation of val function at the end of the chain.

var output = cal(2).add(5).sub(4).val();

Output should be: 3 (2 + 5 - 4)

Loading IDE...