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 trial

JavaScript JavaScript Basics (Retired) Working With Numbers Doing Math

JIAYING LU
JIAYING LU
1,545 Points

About 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!

I 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. `);

2 Answers

Nourez Rawji
Nourez Rawji
3,303 Points
var 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.