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 trialGena Israel
2,047 Pointsdocument.write won't show up
it was working for the first part shown in video but it says there is syntax error in line 9 but i commented that out so im confused as to whats wrong...
3 Answers
Ryan S
27,276 PointsHi Gena,
There are a couple things that are causing problems in your code. First, when making a multi-line comment you need to make sure that you terminate it with a closing */
symbol. Otherwise, it will cause a syntax error.
The other thing has to do with your last document.write()
statement. Since the word "I've" contains an apostrophe, you will need to use double quotes to contain the string instead of single quotes. With single quotes, JavaScript will take the single letter "I" as the first string, then will run into a bunch of words outside of the string (ve been alive for more than ), then the rest of the line (which will also be a bit mixed up due to the quotes). Also, I'm not sure what the '8?' is doing at the end but it will cause problems too.
In that group of words outside the string, JS may find the "for" keyword and treat it as though you want to start a "for" loop, so you may get a syntax error that says you are missing parentheses.
Hope this clears things up.
Siddharth GS
2,698 PointsHi Gena , compare it with my code and see what you've done wrong
console.log('Begin Program');
var secondspermin = 60;
var minsperhour = 60;
var hoursperday = 24;
var daysperweek = 7;
var weeksperyear = 52;
var secondsperyear = secondspermin * minsperhour * hoursperday;
document.write('There are ' + secondsperyear + 'seconds in a day');
var yearsalive = 25;
var yearsalivepersecond = yearsalive * secondsperyear;
document.write("I've been alive for more than " + yearsalivepersecond + " seconds ");
console.log('End Program');
I hope this helps :)
Ryco Baguis
609 Pointsyou are missing back slash on the document.write