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 trialDigital Team
Courses Plus Student 11,346 PointsIs 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 = 27;
var secondsPerWeek = secondsPerDay * daysPerWeek;
var secondsPerYear = secondsPerWeek * weeksPerYear;
var secondsAlive = secondsPerYear * yearsAlive;
document.write('I have been alive for more than ' + yearsAlive);
document.write("</br>");
document.write('There are ' + secondsPerWeek + ' in a week.');
document.write("</br>");
document.write('There are ' + secondsPerYear + ' in a year.');
document.write("</br>");
document.write('I have been alive for ' + secondsAlive + '.');
1 Answer
Shawn Hannah
3,310 PointsThree months ago, but in case anyone stumbles across this.
document.write("</br>"); document.write('There are ' + secondsPerWeek + ' in a week.');
To save yourself the trouble there, just use:
document.write('<br>'There are ' + secondsPerWeek + ' seconds in a week.');
Instead of creating a new document.write for each line-break.