Domanda di colloquio di Paytm

Create a function Given Input sum(1)(2)(3)(4)(); Desired Output 10

Risposta di colloquio

Anonimo

21 mag 2018

function sum(numberOne) { var count = numberOne; return function by(numberTwo) { if (numberTwo === undefined) { return count; } else { count += numberTwo; return by; } } } console.log(sum(1)(4)(66)(35)(3)());