0
Hours
0
Minutes
0
Seconds

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

@Yomesh Gupta
1704

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...