I am learning JS online and they ask me to do a program where the following is done:
For some strange reason which I still do not identify, I only get 2 correct answers. Why is not it still adding to the variable of correct answers? What do I need to modify?
var question1 = prompt("2 + 2 = ?");
var userAnswer1 = parseInt(question1);
var question2 = prompt("Capital de Morelos");
var userAnswer2 = question2.toUpperCase;
var question3 = prompt("Primer dia de la semana");
var userAnswer3 = question3.toUpperCase;
var question4 = prompt("Cuanto vale PI");
var userAnswer4 = parseInt(question4);
var question5 = prompt("8 * 3 = ?");
var userAnswer5 = parseInt(question5);
var userAnswerCorrect = 0;
if( userAnswer1 === 4) {
userAnswerCorrect ++;
}
if( userAnswer2 === "CUERNAVACA" || userAnswer2 === "CUERNA") {
userAnswerCorrect ++;
}
if( userAnswer3 === "LUNES") {
userAnswerCorrect ++;
}
if( userAnswer4 === 3.14 || userAnswer4 === 3.1416) {
userAnswerCorrect ++;
}
if( userAnswer5 === 24 ) {
userAnswerCorrect ++;
}
document.write("<p>You got " + userAnswerCorrect + " answers correct!");
if( userAnswerCorrect === 5) {
document.write("<p>You got a GOLD CROWN!</p>");
} else if( userAnswerCorrect === 4 || userAnswerCorrect === 3 ) {
document.write("<p>You got a SILVER CROWN!</p>");
} else {
document.write("<p>You got a BRONZE CROWN!</p>");
}