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 trialCarleen Hall
Front End Web Development Techdegree Student 3,158 PointsCounter not counting down
Can someone take a second look at my code. The code is fine up until I put in the second counter, this line in particular "var question - =1;" I am going about it just as in the video however JS Bin is telling me that I am missing a semicolon in that line. Can someone show me where? Thx
var visitor = prompt("Hi! What is your name?");
var message = "Hello "+ visitor.toUpperCase() + " Welcome to the Q and A sessions, we are so please that you can join us.";
alert(message);
document.write("We will be asking you a series of five questions. The more questions you answer the bigger the prize. <p>READY!</p>");
document.write("<p>Here goes your first question</p>");
var question = 4;
var questionLeft = "[" + question + " Questions Left]";
var one = prompt("Is Batman and Superman brothers? " + questionLeft);
if (one === "yes"){
alert("That's correct")
} else {
alert ("Wrong! Better luck next time<");
}
var question - =1;
var questionLeft = "[" + questions + " Questions Left]";
var two = prompt("Is the grass really greener on the other side? " + questionLeft);
if (two === "yes"){
alert("That's correct")
} else {
alert ("Wrong! Better luck next time");
}
3 Answers
Carleen Hall
Front End Web Development Techdegree Student 3,158 PointsThanks John! - As you said removing the "var" in front of "question -=1 and questionLeft" fixed it all.
Steven Parker
231,269 Points
You seem to have a stray minus sign (-
) on this line:
var question - = 1;
The message about the semicolon is misleading. Just remove the stray minus.
john larson
16,594 PointsNow that I look at it the var in front of question is recreating that variable, I think. Causing an error BECAUSE I don't think you can -= on a newly created var.
Carleen Hall
Front End Web Development Techdegree Student 3,158 PointsI did exactly what was in Dave video regarding a counter down so I am now a little confused as to why it's not working know. var question - = 1;
john larson
16,594 PointsI commented out
// var question -=1;
// var questionLeft = "[" + questions + " Questions Left]";
and it got rid of the errors. But I don't know why and without those lines your missing part of the functionality I think.
- I tried something else
- I think questions should be question
- and var is unnecessary in front of question -=1;
it seems to works w/out errors after that
john larson
16,594 Pointsjohn larson
16,594 Pointsawesome !