Modo entrevista. Cronômetro de 5 min, sem dicas e sem autocompletar
Ours or not
FácilErrors5 min
The code already has a class NotFoundError. Write a function loadOr(load, fallback). It calls load() and returns the result. If load() throws a NotFoundError, return fallback. Any other error goes on as it is.
Exemplos
loadOr(() => 'Ann', 'guest')Retorna 'Ann'
loadOr(() => { throw new NotFoundError('no user 7'); }, 'guest')Retorna 'guest'
Carregando o editor...
- Without an error returns the result of load
- NotFoundError gives the fallback
- A TypeError goes on
Os testes ocultos rodam no envio