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 trialAlfredo Galli
4,290 Pointshow do you get JavaScript to display the result on a separate line?
I've done the math and all seems to work with the right spacing, but I would love to know how to go down a line, I've tried normal HTML but then it turns out blank xD
The joys of being a newbie
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 secondsAlive = 34 * (secondsPerDay * daysPerWeek * weeksPerYear);
document.write("I've been alive for more then " + secondsAlive + ' seconds');
4 Answers
Patrik Horváth
11,110 Pointsso as i see you use document. .... so you using JS on website so you need HTML into it :)
add to your JS write BR tag represent Break :)
<br>
or use P tag why ? P tag is Block LEVEL element :) you learn more by passing HTML or CSS class :)
document.write("<p> TEXT </p>");
document.write("<p> TEXT 2 </p>");
Henrik Christensen
Python Web Development Techdegree Student 38,322 PointsYou could also use \n which will create a new line.
example
document.write("\nI've been alive for more then " + secondsAlive + ' seconds'); // noticed the \n at the beginning
Corin Ashwell
1,138 PointsThis doesn't work for me.
Jaime Serradell
3,350 PointsWith <br> tag. Like this :
document.write('There are '+ secondsPerDay + ' seconds in a day<br>');
Always inside of the string. Remember when you use an <h1>, <h2>.. or <p> tags, carriage return is included, it's not necessary put a <br> tag at the end. Hope i've help.
amy andro
112 Pointsdocument.write("I've been alive for more than " + secondsAlive + " seconds "