Modo entrevista. Temporizador de 5 min, sin pistas y sin autocompletado
Sum step by step
FácilTypeScript 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.
Ejemplos
sum(1)(2)(3)Devuelve 6
(() => { const plusFive = sum(2)(3); return [plusFive(1), plusFive(10)]; })()Devuelve [ 6, 15 ]
Función
Cargando el editor…
- sum(1)(2)(3) is 6
- sum(10)(0)(-4) is 6
Las pruebas ocultas se ejecutan al enviar