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

Yashwanth Yash
Yashwanth Yash
10,947 Points

Did i solve it right?

Did i solve the problem correctly?

var secPerMin = 60;
var minsPerDay = 60;
var hoursPerDay = 24
var daysPerWeek = 7;
var weeksPerYear = 52;
var secondsPerDay = secPerMin * minsPerDay *hoursPerDay ;
document.write(secondsPerDay);
var yearsAlive = 22 * secondsPerDay * 365;
document.write("<br><h2>I've been alive for more than "+ yearsAlive + " seconds. </h2>")

4 Answers

It seems right, yes. But for clarity, the variable minsPerDay should be named minsPerHour which is equal to 60

Yashwanth Yash
Yashwanth Yash
10,947 Points

Thanks. I missed it somehow.

Nouh Ahmed
Nouh Ahmed
7,085 Points

Thanks. I multiplied secondsPerDay * dayPerWeek * weeksPerYear to get how many seconds in a year.

var yearsAlive = secondsPerDay * daysPerWeek * weekPerYear * 26; Your solution is nice.

Hi, this is actually a question, what does <br> mean?

Ruby Bassi
Ruby Bassi
3,873 Points

<br> is a line break.

To make it more interesting and interactive, try this:

var age = prompt("Hello! Please enter your age."); age = parseInt(age); var secondsAlive = secondsPerDay * daysPerWeek * weeksPerYear; secondsAlive *= age; document.write("You have been alive for " + secondsAlive + " seconds now. Good job!");