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 trialJIAYING LU
1,545 PointsAbout print out the seconds i've been alive.
var secondPerMin = 60; var minPerHour = 60; var hourPerDay = 24; var dayPerWeek = 7; var weekPerYear= 52; var secondPerDay = secondPerMin * minPerHour * hourPerDay; document.write('There are ' + secondPerDay + ' seconds in a day.');
var yearsAlive = 29; var x = yearsAlive * weekPerYear * dayPerWeek * secondPerDay; document.write('I have been alive more than ' x ' seconds!' );
Why it doesn't go through? Thanks!
2 Answers
Nourez Rawji
3,303 Pointsvar yearsAlive = 29;
var x = yearsAlive * weekPerYear * dayPerWeek * secondPerDay;
document.write('I have been alive more than ' + x + ' seconds!' );
You just forgot to concatenate the text and the variable in your document.write() statement. Remember, any time you wanna stick stuff together in a string you've gotta use + to connect them.
JIAYING LU
1,545 Pointsoh hey thamks!
Tomas Svojanovsky
26,680 PointsTomas Svojanovsky
26,680 PointsI think you are missing something. You have two options how to join string with variables. The first is as you did document.write('There are ' + secondPerDay + ' seconds in a day.'); and the second document.write(
`There are ${secondPerDay} seconds in a day.
`);