I was trying to build an MCT calculator in javascript, however during the creation of the median, I kept getting errors. This is my code: (Keep in mind I am relatively new to javascript)
var min = prompt("Enter minimum value");
var max = prompt("Enter maximum value");
if (min > max) {
alert("Error:\n\n\nMinimum value '" + min + "' is greater than Maximum value '" + max + "'");
} else {
var a = (max - min);
alert("variable a is " + max + " - " + min + " = " + a);
var b = a / 2;
alert("variable b is " + a + " / 2 = " + b);
var c = min + b;
alert("variable c is " + min + " + " + b + " = " + c);
alert("Range is " + a + "\n\nMedian is " + c + "\n\nMin is " + min + "\n\n Max is " + max);
}
If you type in 5 for minimum value and 10 for maximum value, it will tell you 5 is larger than 10, but it isn't.. And if you type 10 for minimum value and 15 for maximum value, it will have the median be 102.5 rather than 12.5 I do not get this at all, please help :)