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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Brett Walford](https://secure.gravatar.com/avatar/81052c76065bdc8afb56dfc9b6bcbc3c?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Brett Walford
3,877 PointsHow do you get the seconds alive integer to be displayed with the appropriate commas?
I completed the task and got the answer to how many seconds I've been alive, but it displays it as an integer without commas. How can I get it to display commas?
3 Answers
![Abraham Juliot](https://uploads.teamtreehouse.com/production/profile-photos/1442392/micro_4mXoKqNG.jpg)
Abraham Juliot
47,353 PointsUse the .toLocaleString() method on the number. More info at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString
![Jeffrey Libatique](https://uploads.teamtreehouse.com/production/profile-photos/8487902/micro_IMG_20170205_063401.jpg)
Jeffrey Libatique
6,701 PointsSame here! hahaha! It worked! Thanx!
![Teacher Russell](https://uploads.teamtreehouse.com/production/profile-photos/8280332/micro_WIN_20181017_08_19_07_Pro__2_.jpg)
Teacher Russell
16,873 PointsCan I see how you used that with document.write? I don't understand.
![Christopher Phillips](https://uploads.teamtreehouse.com/production/profile-photos/8811112/micro_Resume_Pic.jpg)
Christopher Phillips
10,061 PointsRussell, I'm pretty new to this myself but I did a bit of research because I was curious as well. It seems you first have to define a new variable that calculates the total seconds in a day. You can't just use the mathematics along with the .toLocaleString() command (I may be incorrect here).
So you could add:
var secondsPerDay = secondsPerMin * minPerHour * HourPerDay;
Your message var:
var message = 'There are ' + secondsPerDay.toLocaleString() + ' seconds in a day';
Then finally:
document.write(message);
![Nathan Kilcourse](https://secure.gravatar.com/avatar/f711e53e5025408a0937e7681fc8e18d?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Nathan Kilcourse
531 Pointsawesome, thanks you.
![Teacher Russell](https://uploads.teamtreehouse.com/production/profile-photos/8280332/micro_WIN_20181017_08_19_07_Pro__2_.jpg)
Teacher Russell
16,873 PointsChristopher, thanks a lot! Nice and simple.
Brett Walford
3,877 PointsBrett Walford
3,877 PointsAwesome! Thanks, that worked!
Teacher Russell
16,873 PointsTeacher Russell
16,873 PointsSorry, how do you use that with document.write?
Brett Walford
3,877 PointsBrett Walford
3,877 PointsHey Russel, this is what I did:
var secondsPerMin = 60;
var minsPerHour = 60;
var hoursPerDay = 24;
var daysPerWeek = 7;
var weeksPerYear= 52;
var secondsPerDay = secondsPerMin * minsPerHour * hoursPerDay;
document.write("<h3>There are " + secondsPerDay.toLocaleString() + " seconds in a day.</h3>");
var yearsAlive= 34;
var secondsAlive = secondsPerDay * daysPerWeek * weeksPerYear * yearsAlive;
document.write("<br><h2>You have been alive for more than " + secondsAlive.toLocaleString() + " seconds.</h2>");