Sum step by step
EasyTypeScript types5 min
Write a function sum that is called three times in a row, sum(a)(b)(c). Each call gets a number, and the last one returns the sum of the three numbers.
Every step must be typed, with no any. Do not change the code at the bottom, each line after @ts-expect-error must stay a type error.
Examples
sum(1)(2)(3)Returns 6
(() => { const plusFive = sum(2)(3); return [plusFive(1), plusFive(10)]; })()Returns [ 6, 15 ]
Function
Loading the editor...
- sum(1)(2)(3) is 6
- sum(10)(0)(-4) is 6
Hidden tests run on Submit