create a sum()
2022年5月1日小于 1 分钟
create a sum()
Question
Create a sum()
, which makes following possible
const sum1 = sum(1)
sum1(2) == 3 // true
sum1(3) == 4 // true
sum(1)(2)(3) == 6 // true
sum(5)(-1)(2) == 6 // true
Code
/**
* @param {number} num
*/
function sum(num) {
// your code here
}