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 trialAyan Kundu
1,194 Pointscode is not working..
var Question = 3; var Question_Left = '[' + Question + ' Question Left ]' ; var GirlFriendFirst = prompt(" Enter The Girlfriend Name " + Question_Left );
var Question -= 1; var Question_Left = '[' + Question + ' Question Left ]' ; var GirlFriendSecond = prompt(" Enter The Girlfriend Name " + Question_Left );
var Question -= 1; var Question_Left = '[' + Question + ' Question Left ]' ; var GirlFriendThird = prompt(" Enter The Girlfriend Name " + Question_Left );
alert(" All done And set for Print ");
var AllGirlFriend = " I love " + GirlFriendFirst + " More then Anything "; AllGirlFriend += " But i used to love " + GirlFriendSecond + " a lot, but she never loved me "; AllGirlFriend += " Now i love " + GirlFriendThird + " A lot She is my life now";
document.write(" My Love story: " + AllGirlFriend);
3 Answers
Tan Dung
Courses Plus Student 80 Pointsvariable: Question Left where???
Ayan Kundu
1,194 Pointsvar Question = 3; var Question_Left = '[' + Question + ' Question Left ]' ; var GirlFriendFirst = prompt(" Enter The Girlfriend Name " + Question_Left );
var Question -= 1; var Question_Left = '[' + Question + ' Question Left ]' ; var GirlFriendSecond = prompt(" Enter The Girlfriend Name " + Question_Left );
var Question -= 1; var Question_Left = '[' + Question + ' Question Left ]' ; var GirlFriendThird = prompt(" Enter The Girlfriend Name " + Question_Left );
alert(" All done And set for Print ");
var AllGirlFriend = " I love " + GirlFriendFirst + " More then Anything "; AllGirlFriend += " But i used to love " + GirlFriendSecond + " a lot, but she never loved me "; AllGirlFriend += " Now i love " + GirlFriendThird + " A lot She is my life now";
document.write(" My Love story: " + AllGirlFriend);
Idan Melamed
16,285 PointsHi Ayan
Let me paste your code again:
var Question = 3;
var Question_Left = '[' + Question + ' Question Left ]' ;
var GirlFriendFirst = prompt(" Enter The Girlfriend Name " + Question_Left );
var Question -= 1;
var Question_Left = '[' + Question + ' Question Left ]' ;
var GirlFriendSecond = prompt(" Enter The Girlfriend Name " + Question_Left );
var Question -= 1;
var Question_Left = '[' + Question + ' Question Left ]' ;
var GirlFriendThird = prompt(" Enter The Girlfriend Name " + Question_Left );
alert(" All done And set for Print ");
var AllGirlFriend = " I love " + GirlFriendFirst + " More then Anything ";
AllGirlFriend += " But i used to love " + GirlFriendSecond + " a lot, but she never loved me ";
AllGirlFriend += " Now i love " + GirlFriendThird + " A lot She is my life now";
The problem with the code is that you used the keyword "var" in a few places where JavaScript don't know what to do with it.
Only use "var" when you declare a variable for the first time. The reason the code is not working, is that you used "var" on the same variable a few times.
For example, on line 1, you write: var Question = 3; And then on line 5 you write: var Question -= 1;
Your last 3 lines of code are a perfect example of how to use "var" correctly! So delete all the unnecessary "vars" in your code, and it should work.
I hope this helps, Idan.