Yes or no
EasyFunctions3 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.
Examples
ask(true, () => 'ok', () => 'cancel')Returns 'ok'
ask(false, () => 'ok', () => 'cancel')Returns 'cancel'
Loading the editor...
- With true returns the result of yes
- With false returns the result of no
Hidden tests run on Submit