Code Lab

Modo entrevista. Cronômetro de 3 min, sem dicas e sem autocompletar

Yes or no

FácilFunctions3 min

Write a function ask(agree, yes, no). yes and no are functions too, they are callbacks.

If agree is true, call yes, otherwise call no. Return what the called function returned.

Exemplos

ask(true, () => 'ok', () => 'cancel')

Retorna 'ok'

ask(false, () => 'ok', () => 'cancel')

Retorna 'cancel'

Fonte

Carregando o editor...
  1. With true returns the result of yes
  2. With false returns the result of no

Os testes ocultos rodam no envio