JSFiddle - React, Tailwind, and code Playground

JavaScript

function checkImage (src, good, bad) {
    var img = new Image();
    img.onload = good; 
    img.onerror = bad;
    img. src = src;
}

checkImage( "http://jsfiddle.net/img/logo.png", function(){ alert(this.src + " " + "good"); }, function(){ alert("bad"); } );

checkImage( "foo.gif", function(){ alert("good"); }, function(){ alert(this.src + " " + "bad"); } );