So, I was just watching a tutorial from WebDevSimplified, and here is that piece of code that bothers me.
const failure1 = false;
const failure2 = false;
function callbackFunction(callback, errorCallback) {
if (failure1) {
errorCallback({
name: 'Negative event1 occurred',
message: ':('
})
} else if (failure2) {
errorCallback({
name: 'Negative event2 occurred',
message: ':/'
})
} else {
callback('Mission complete!')
}
}
callbackFunction((message) => {
console.log('Success: ' + message)
}, (error) => {
console.log(error.name + ' ' + error.message)
})
So, why exactly is there a value assigned to the function parameters like this:
callback('Mission complete!')
Because according to every information I found on the internet I would do it like this:
callback = 'Mission complete'
Yet, when I do it this way, it's not working. I really feel super bad right now, because this seems very trivial and I cannot find any information about it. I would really appreciate it if someone would explain it to me.