First of all, please change your post to have [ code ] and [ /code ] around your code example. Otherwise it is really unreadable
Yet ... the very first function looks like this
Code:
function show_alert0() {
{counter++;}
if (randomname0 != final) {
alert("Sorry." + (( correct / counter ) * 100 ));
} else {
correct++;
}
{alert("Congrats!" + (( correct / counter ) * 100 ));}
}
which tells me that you have absolutely no idea about the usage of curly brackets. With curly brackets you enclose a logial group of statements (not just one) that will then be executed sequentially (in case of certain conditions).
In your case the bottom most alert is inside of curly brackets OUTSIDE(!) of the else part of the if statement. This will make the alert appear no matter what the result of the if condition was.