Here is the code I have been working on:
myObject.myMethod('imageCheck', function () {
var image = new Image();
image.onerror = function() {
return false;
};
image.onload = function() {
return true;
};
image.src = 'http://www.example.com/image.jpg';
});
Unfortunately, the code is not functioning as expected. It seems that the return statements only exit the anonymous functions, not the imageCheck function itself. How can I modify this to ensure that the entire function returns either true or false?