I am currently trying to understand Node and callbacks, and have tried various solutions to this code in order to get it to work, however param2 is coming back undefined. Can anybody tell me why? And how to fix this? Thanks!
function getPage(callback) {
url = 'http://www.google.com';
if (url) {
url = url;
} else {
console.log('There was an error. No URL submitted');
}
callback(url, param2);
}
function CB(url, param2) {
console.log(`The URL of the page requested was ${url} and the added argument was ${param2}`);
}
getPage(CB);