Write a JavaScript callback for the jQuery function
$(\"#sort\").click
. Allow the user to enter three numbers in any order. Output the numbers in ord
Try
$("#sort").on("click", function (e) {
var vals = $.map($("#a, #b, #c"), function (v, k) {
return Number(v.value)
})
, min = null
, msg = "";
do {
min = Math.min.apply(Math, vals);
msg += min;
vals.splice($.inArray(min, vals), 1)
} while (vals.length > 0);
$("output").html(msg)
});
$("#sort").on("click", function (e) {
var vals = $.map($("#a, #b, #c"), function (v, k) {
return Number(v.value)
})
, min = null
, msg = "";
do {
min = Math.min.apply(Math, vals);
msg += min;
vals.splice($.inArray(min, vals), 1)
} while (vals.length > 0);
$("output").html(msg)
});