Exercise on Default Arguments
It's time to play with function arguments.
We'll cover the following...
Exercise 1:
Write a function that executes a callback function after a given delay in milliseconds. The default value of delay is one second.
The setTimeout()
method can be used to specify the time delay before a function is executed.
function executeCallback( callback, delay ) {console.log('Delay: ' + delay);}//Edit above this lineexecuteCallback( () => console.log('Done'));
Explanation:
The main objective of this exercise was to define a default argument for delay
.
Using ES6 conventions, we can simply ...