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

Did I do it right

var seconsdsPerMin = 60;
var minsPerHour = 60;
var hoursPerday = 24;
var daysPerWeek = 7;
var weeksPerYear = 52;
var daysPerYear= 365;
var yearsAlive = 22;
var secondsAlive = seconsdsPerMin * minsPerHour * hoursPerday * daysPerYear * yearsAlive;
document.write('I have been alive for more than ' + secondsAlive + ' seconds');

MOD EDIT added code formatting for readability.

5 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Kalina,

Yes, your code is correct. It does the math and does display it to the browser screen.

Good Job. :thumbsup:

Oh okay thank you so much and also for the visual. I didnt know how to display the code in the editor. but thank you MOD

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

You are very Welcome.

If you want to learn other tricks, there is a Markdown CheatSheet under the box where you type in your questions. Also, if you click on "edit question" on your original question here, you will see where I added the 3 backticks with the language name and closed off the block with another 3 backticks. This formats the code into a nicely formatted block.

I hope you enjoy your learning path here on Treehouse. :smiley:

Thomas Beaudry
Thomas Beaudry
29,084 Points

Kalina, your syntax looks right however he asks you to put in your age and calculate it on your page, with actual numbers etc, best of luck!

Yes, I put my age 22 (var years Alive = 22;) But I wondered did I calculate the seconds right? Thanks for commenting!

Thanks for letting me know!

You may want tor reuse a value for "secondsPerDay".

var daysPerYear= 365; var yearsAlive = 22; var secondsAlive = secondsPerDay daysPerYear yearsAlive;

Eduardo Calvachi
Eduardo Calvachi
6,049 Points

Great answer kalina edwards. Since we already calculated secondsPerDay, We could also get secondsAlive by multiplying it to the 365 days in a year and multiplying that by the years alive, like this:

var secondsAlive = secondsPerDay * 365 * yearsAlive;