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!
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
Marissa Smith
16,609 PointsWhats wrong with my JavaScript code?
var QsLeft = 3;
var questions= ("[There are " + QsLeft + " questions left]");
var ask= prompt(" sup? " + questions);
var ask2= prompt('how are you?' + minusOne());
function minusOne(){
QsLeft=-1;
return(questions);
}
2 Answers

Cooper Runstein
11,849 PointsYou're reassigning the value of Qsleft in your function, you should be doing something closer to:
QsLeft -= 1;

Marissa Smith
16,609 PointsI changed QsLeft to -=1 and it's not working, is there something else I'm not catching?

Cooper Runstein
11,849 PointsWell I'm not entirely positive what it is you want this code to do. I recommend you add some comments to your code explaining what you expect each line to do, and include one or two lines at the beginning describing what you want this piece of code to do, post it as a comment, and I can help you figure out where you're going wrong. Or in the process of thinking each line over, you might figure out whats going wrong on your own.
Cooper Runstein
11,849 PointsCooper Runstein
11,849 PointsFormat as code next time!