Here is one way to have a callback return a value:
function tens(value, callback) {
return callback(10*value)
}
var n = tens(100, function(result){ return result })
n
1000
Here is another way:
function tens(value, callback) {
return callback(10*value)
}
var n = tens(150,
function(err, result) {
if (err) throw err
else return result
})
n
1500
The trouble with the way I posed the question is that
function test() {
var score0 = 16;
return score0;
}
would have worked just as well. And if this simplified syntax works just as well, then the function "callback" in my original question is not a callback function but a function that I called by coincidence "callback"
return callback();will do the job.