The jsfiddle.net code below produces Uncaught SyntaxError: Unexpected token (
and the text "Here", but does not produce the result I wish to study, which will help me understand callbacks in functions and how their return
value, true/false in my case, can be used to determine which of two things are to be computed.
I would like help removing the syntax error so I can see the result.
function checkPos(input, callback) {
if (input > 0)
function () {
callback(true);
} else
function () {
callback(false);
}
}
function dosomething(number) {
var diff = 10 - number;
checkPos(diff, function (e) {
return e;
});
}
var count = 1;
var multiplier = 6;
var result;
if (dosomething(11)) result = 5 + count
else result = 5 - count
document.getElementById("demo").innerHTML = String(result*multiplier);
The html code is simply as follows.
<body>Here
<p id="demo"></p>
</body>