(function () {
'use strict';
function fetchData(callback) { // create the first (outer) function
const data = 'get data from an API';
setTimeout(() => {
callback(data); // use the callback param as a function and pass in the data value
}, 1000);
}
function displayData(data) { // create the inner function that takes in the callback as a param
console.log('processing data');
console.log(data);
}
fetchData(displayData); // finally call the outer function with the inner function as a value
})();