Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements The Conditional Challenge Solution

Mariana Castilho
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Mariana Castilho
Front End Web Development Techdegree Graduate 13,842 Points

Can't understand why the program is not prompting nothing

When I start the programming nothing happens and I can't understand why. Somebody can help me please? My code is below:

var question1 = 'Quanto são 4 * 3?' ;
var question2 = 'Quanto são 4 * 5?' ;
var question3 = 'Quanto são 4 * 4?' ;
var question4 = 'Quanto são 4 * 6?' ;
var question5 = 'Quanto são 4 * 7?' ;

var correctAnswer1 = 12;
var correctAnswer2 = 20;
var correctAnswer3 = 16;
var correctAnswer4 = 24;
var correctAnswer5 = 28;

var score = 0; 

var userAnswer1 = prompt(question1);

if (parseInt(userAnswer1) === correctAnswer1) {
  score += 1;
}

var userAnswer2 = prompt(question2);

if (parseInt(userAnswer2) === correctAnswer2) {
  score += 1;
}

var userAnswer3 = prompt(question3);

if (parseInt(userAnswer3) === correctAnswer3) {
  score += 1;
}


var userAnswer4 = prompt(question4);

if (parseInt(userAnswer4) === correctAnswer4 {
  score += 1;
}


var userAnswer5= prompt(question5;

if (parseInt(userAnswer5 === correctAnswer5 {
  score += 1;
}

var finalMessage = 'Você acertou  ' + score + ' de 5 perguntas';

alert(finalMessage);

2 Answers

rydavim
rydavim
18,814 Points

Your code is fairly solid, you're just missing some syntax problems with parentheses. On lines 36, 41, and 43 you're missing one or more closing parentheses.

var userAnswer4 = prompt(question4);

if (parseInt(userAnswer4) === correctAnswer4) { // HERE
  score += 1;
}


var userAnswer5= prompt(question5); // HERE

if (parseInt(userAnswer5) === correctAnswer5) { // HERE (2)
  score += 1;
}

Fixing those minor errors should get your prompts working. Everything ran as expected for me after making those changes. Keep up the good work, and happy coding!