Unit 4 Lesson 7 Chronotype - Fixing the Conditionals

The Example Solution provided does not cover certain combinations and /or gives the wrong profiles for certain combinations.

Ex1: BedTime: 10, Waketime: 7, Type: light. The result for this is a lion, but the lion has as Waketime 6 or earlier.

Ex2: BedTime: 12, Waketime: 6, Type: heavy. The result for this is a lion, but the bedTime for the lion should be 10 or earlier.

I have two different solutions:

  1. My colleague Dana C. altered the order of the conditions and added one option for “not found” . No picture will be displayed.

  2. I included the “not found” option, but I also changed the design and added a “Pick” option for each category. This way, when the program is run for the first time it isn’t pre loaded with 8, 4 and light. I used the following code to show the message “Must Pick”. No picture will be displayed.

if (sleeperType == “Pick” || isNaN(bedTime) || isNaN(wakeTime)) {
setText(“profileOutput”, “Must Pick”);

Solution 1

Solution 2 Link

1 Like