Code Lab

Modo entrevista. Temporizador de 3 min, sin pistas y sin autocompletado

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.

Ejemplos

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

Devuelve 'ok'

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

Devuelve 'cancel'

Fuente

Cargando el editor…
  1. With true returns the result of yes
  2. With false returns the result of no

Las pruebas ocultas se ejecutan al enviar