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

Erik L
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Erik L
Full Stack JavaScript Techdegree Graduate 19,470 Points

This is my code, I hope I did it correctly

So it took me a while to understand the challenge, the instructor wasn't kidding when he said we needed to make some multiplications, this is my code I hope I did it correctly:

var secondsPerMin= 60;
var minsPerHour = 60;
var hoursPerDay= 24;
var daysPerWeek= 7
var weerksPerYear= 52;
var daysPerYear= 365;
var secondsPerDay = secondsPerMin * minsPerHour * hoursPerDay;
document.write('<h1>There are ' + secondsPerDay + ' seconds in a day</h1>')

var yearsAlive= 23;
var totalSecondsAlive= yearsAlive * daysPerYear * hoursPerDay * minsPerHour * secondsPerMin;
document.write('<h1>I\'ve been alive for more than ' + totalSecondsAlive + ' seconds</h1>')

3 Answers

Hi Erik, you are missing semicolons in the document.write functions and in line four. In line five, it looks like you misspelled 'weeks' and instead wrote 'weerks'. If you aren't sure if your code was written correctly, check the preview if it a challenge and developer tools if it is in a Chrome web page. For the shortcut to dev tools, hold down 'command', 'shift', and 'i'. Hope this helps :)

Erik L
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Erik L
Full Stack JavaScript Techdegree Graduate 19,470 Points

I see, thanks for your input, the shortcut for the developer tools you mentioned don't work as I'm taken to my email page instead of the dev tools, for the dev tools shortcut you have to type (command)+(option)+(i), you type (option) instead of (shift)

This is what my code looks like...

var secondsPerMin = 60; var minsPerHour = 60; var hoursPerDay = 24; var daysPerWeek = 7; var weeksPerYear = 52; var daysPerYear = 365;

var secondsPerDay = secondsPerMin * minsPerHour * hoursPerDay; document.write('There are ' + secondsPerDay + ' seconds in a day'); var yearsAlive = 26; document.write(" I've been alive for more than " + yearsAlive * daysPerYear * secondsPerDay + " seconds.")

since you already have the secondsPerDay variable you only need to multiple your yearsAlive variable by your daysPerYear variable.

obviously yours works too just the above is a little shorter and makes use of one of our declared variables.

Whoops. My bad! Sorry about that.