Mode entretien. Minuteur de 3 min, sans indices ni autocomplétion
Function types
FacileTypeScript types3 min
The function greet(name, times) returns a string where the greeting Hi, <name>! is repeated times times, separated by spaces. Add the parameters with types, set the return type and write the function body.
Do not change the code at the bottom. Each line after @ts-expect-error must stay a type error.
Exemples
greet('Ann', 2)Renvoie 'Hi, Ann! Hi, Ann!'
greet('Bob', 1)Renvoie 'Hi, Bob!'
greet('Ann', 0)Renvoie ''
Fonction
Chargement de l'éditeur...
- Entrée
greet('Ann', 2)Attendu'Hi, Ann! Hi, Ann!' - Entrée
greet('Bob', 1)Attendu'Hi, Bob!'
Les tests cachés se lancent à la soumission