Callbacks Practice
Exercise: callback me maybe
- Create a function called
telephone that logs "867-5309" when called.
- Write a separate function called
blondie that takes a callback function as an argument.
- When called,
blondie should log "Call me on the line at ", then execute the callback function it received as an argument.
- Run
blondie with telephone passed in as an argument.
Exercise: repeater
- Create a function called
repeater that takes an integer and a string as arguments.
- When called, the function should log the string to the console as many times as indicated by the integer.
- Write a separate function called
repeaterSetUp that takes an integer, a string, and a callback function as arguments.
- When called,
repeaterSetUp should log "HERE WE GO" to the console, and then pass the integer and string to the callback function passed to it, which then executes.
- Run
repeaterSetUp with repeater as the callback function, so if repeaterSetUp is passed 3 and "oi!", the terminal should print:
HERE WE GO
oi!
oi!
oi!