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 trialYashwanth Yash
10,947 PointsDid 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
magnusluca
2,792 PointsIt seems right, yes. But for clarity, the variable minsPerDay should be named minsPerHour which is equal to 60
Nouh Ahmed
7,085 PointsThanks. I multiplied secondsPerDay * dayPerWeek * weeksPerYear to get how many seconds in a year.
var yearsAlive = secondsPerDay * daysPerWeek * weekPerYear * 26; Your solution is nice.
Daphne Orme
2,275 PointsHi, this is actually a question, what does <br> mean?
Ruby Bassi
3,873 Points<br> is a line break.
Dennis Amiel Domingo
17,813 PointsTo 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!");
Yashwanth Yash
10,947 PointsYashwanth Yash
10,947 PointsThanks. I missed it somehow.