Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Allison Davis
Allison Davis
12,698 Points

First web app -seeking feedback

Hi all, I've been working on a simple web app that calculates an ideal bedtime based on number of complete sleep cycles and when you need to get up. Take a look and tell me what you think!

As you can see in the workspaces version vs. the CodePen, I couldn't get the font to appear consistently across browsers. [Update: this is fixed now.]

https://w.trhou.se/cptl3pjlut

http://codepen.io/davisdavis/pen/pJdvjM/

3 Answers

Colin Marshall
Colin Marshall
32,861 Points

Cool idea!

If I put in that I want to wake up at 8:00am it tells me I should go to bed at: 5:00 AM 3:30 AM 2:00 AM 12:30 PM 11:00 PM 9:30 PM

Are you still working on that part of it? Seems something is off if it is telling me to go to bed at those times.

Allison Davis
Allison Davis
12,698 Points

Thank you!

It's counting backwards by sleep cycle. Each one is 90 minutes, and it starts with two cycles (since no one probably ever wants just 90 minutes of sleep!). The calculations are correct but the way it's displaying isn't the most intuitive. Next on the list is either changing the loop to subtract instead of add to the counter, or reverse sort the times generated by the loop.

Colin Marshall
Colin Marshall
32,861 Points

Ok I get it now! There is an error though. 12:30PM should be 12:30AM in my example for waking up at 8:00AM. That's why I was thrown off.

Seth Kroger
Seth Kroger
56,407 Points

Strangely it doesn't work in Firefox, but does in Chrome and IE. Instead it posts the form which means that this isn't working as it's supposed to:

$("#wakeup").submit(function() {
//...
   event.preventDefault();

But if you add event as the parameter is works.

$("#wakeup").submit(function(event) {

Apparently Chrome and IE give a you sensible default for event but Firefox needs it declared explicitly. (I did not know this going in, so I learned something too.)

Allison Davis
Allison Davis
12,698 Points

How strange! Thanks for the catch. I tested in Chrome and Safari but hadn't done so in Firefox yet.

Styling the form elements has been really challenging - in Chrome, I can get them to appear more or less how I'd like them to, but in other browsers they can be all over the place. If anyone has any fixes or ideas, there, would love to hear them.

Thanks everyone for taking a look!