Modo entrevista. Temporizador de 3 min, sin pistas y sin autocompletado
Function types
FácilTypeScript 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.
Ejemplos
greet('Ann', 2)Devuelve 'Hi, Ann! Hi, Ann!'
greet('Bob', 1)Devuelve 'Hi, Bob!'
greet('Ann', 0)Devuelve ''
Función
Cargando el editor…
- Entrada
greet('Ann', 2)Esperado'Hi, Ann! Hi, Ann!' - Entrada
greet('Bob', 1)Esperado'Hi, Bob!'
Las pruebas ocultas se ejecutan al enviar