Code Lab

Mode entretien. Minuteur de 5 min, sans indices ni autocomplétion

Sum step by step

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

Exemples

sum(1)(2)(3)

Renvoie 6

1 + 2 + 3 is 6.
(() => { const plusFive = sum(2)(3); return [plusFive(1), plusFive(10)]; })()

Renvoie [ 6, 15 ]

The function from the middle step can be called many times.

Source

Fonction
Chargement de l'éditeur...
  1. sum(1)(2)(3) is 6
  2. sum(10)(0)(-4) is 6

Les tests cachés se lancent à la soumission