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

Time Calculator not working.

I was following along in the 'Doing Math' session. I typed in the code for the Time Calculator, (as in the tutorial), but the answer did not print to the document in the browser. Everything appears the same as in the tutorial, (not sure why it isn't working).

The browser shows the Time Calculator heading, but no writing from javascript, (I also checked that there is links to the javascript document in the html file).

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

This is going to be easiest to troubleshoot if we can see a snapshot of your workspace. But also check the basics: make sure you saved your file, refresh the webpage and possibly clear the browser cache :sparkles:

Here is a copy of my workspace:

https://w.trhou.se/edoxcmrltp

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there kirstanfitzpatrick! Sorry for the delay in getting back to you. I located the problem. In your JavaScript file, you have written this:

var hoursPerDay = 24:

That should be:

var hoursPerDay = 24;

Note the replacement of the colon with a semicolon :smiley: Hope this helps! :sparkles:

The Time Calculator didn't show any results. My code was the same as the instructor's:

var secondsPerMin = 60;
var minsPerHour = 60;
var hoursPerDay = 24;
var daysPerWeek = 7;
var weeksPerYear = 52;
var secondsPerDay = secondsPerMin * minPerHour * hoursPerDay;
document.write('There are ' + secondsPerDay + ' seconds in a day');

Moderator edited: Markdown added so that code renders properly in the forums.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! No, your code is not the same as the instructor's and should have generated an error in the console.

You wrote:

var secondsPerDay = secondsPerMin * minPerHour * hoursPerDay;

But you meant to write:

var secondsPerDay = secondsPerMin * minsPerHour * hoursPerDay;

Note the difference between minPerHour and minsPerHour. The first one is undefined, while the second one is not.

Thanks Moderator. Not sure how to add a markdown...

Jennifer,

Thanks for pointing that out. I literally looked at the code over a dozen times and could not distinguish the difference.