Modo entrevista. Cronômetro de 3 min, sem dicas e sem autocompletar
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.
Exemplos
greet('Ann', 2)Retorna 'Hi, Ann! Hi, Ann!'
greet('Bob', 1)Retorna 'Hi, Bob!'
greet('Ann', 0)Retorna ''
Função
Carregando o editor...
- Entrada
greet('Ann', 2)Esperado'Hi, Ann! Hi, Ann!' - Entrada
greet('Bob', 1)Esperado'Hi, Bob!'
Os testes ocultos rodam no envio