Write a JavaScript callback for the jQuery function
$("#sort").click
. Allow the user to enter three numbers in any order. Output the numbers in order from lowest to highest.
$(document).ready(function() {
$("#sort").click(function() {
var a = Number($("#a").val());
var b = Number($("#b").val());
var c = Number($("#c").val());
var message = "";
if (b > c) {
if ((b + c) > (a + c)) {
message = c + " " + a + " " + b;
} else {
message = c + " " + b + " " + a;
}
} else {
message = b + " " + a + " " + c;
}
if (b > a) {
if ((a + b) > (a + c)) {
message = a + " " + c + " " + b;
} else {
message = a + " " + b + " " + c;
}
} else {
message = b + " " + c + " " + a;
}
$("#output").html(message)
});
});
Would anyone mind looking at this code and saying what's wrong?