The result from the 'If' statement is always the last one shown.
Take a look at this code snippet:
function calc(on, ep, am, ek, b1, b2, b3, b4) {
var sum, mo;
b1 = parseInt(b1);
b2 = parseInt(b2);
b3 = parseInt(b3);
b4 = parseInt(b4);
sum = b1 + b2 + b3 + b4;
mo = sum / 4;
if (mo < 5) {
x = "Not Good";
}
if (mo < 6.5 && mo > 4.99) {
x = "Good";
}
if (mo < 8.5 && mo > 6.49) {
x = "Really Good";
}
if (mo > 8.49) {
x = "Perfect";
}
alert("O " + on + " " + ep + " " + am + " who is in " + ek + "th semester had averaged " + mo + " " + x);
}