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

Is this right?

var secondsPerMin = 60; var minsPerHour = 60; var hoursPerDay = 24; var daysPerWeek = 7; var weeksPerYear = 52; var secondsPerDay = secondsPerMin * minsPerHour * hoursPerDay; document.write("There are " + secondsPerDay + " seconds in a day ");

var yearsAlive = 26 var secAlive = yearsAlive * secondsPerDay * 365; document.write("I've been alive for more than " + secAlive + " seconds.");

3 Answers

Great Job. Everything looks great. Might be a copy/paste typo but you're missing a semicolon after var yearsAlive = 26

virus200
virus200
6,583 Points

This was how I did mine. Yours works to and I am no expert but multiplying by 365 directly I believe is called hardcoding a number and I think generally people try to avoid doing that.

var yearsAlive = 27;
var secondsAlive = secondsPerDay * daysPerWeek * weeksPerYear * yearsAlive;
document.write('I have been alive for' + secondsAlive + ' seconds');
hapaman
seal-mask
.a{fill-rule:evenodd;}techdegree
hapaman
Full Stack JavaScript Techdegree Student 3,026 Points
var secondsPerMinute = 60;
var minutesPerHour = 60;
var hoursPerDay = 24;
var daysPerWeek = 7;
var weeksPerYear = 52;
var daysPerYear = 365;

var secondsPerDay = secondsPerMinute * minutesPerHour * hoursPerDay; 
document.write("There are " + secondsPerDay + " seconds per day.<br>");

var myAge = 99;
var dougYearsAlive = secondsPerDay * daysPerYear * myAge;
document.write("I've been alive for " + dougYearsAlive + " seconds!");