Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix telling_time_2 validator for case where hour and minute hand are …

…in the same place

fix #20312
  • Loading branch information...
commit 1530e0883e85a7b3fba5505f43b0d59f7ae18c1b 1 parent 78735b6
@beneater beneater authored
Showing with 10 additions and 7 deletions.
  1. +10 −7 exercises/telling_time_2.html
View
17 exercises/telling_time_2.html
@@ -214,14 +214,17 @@
if (minuteAngle === minuteStartAngle && hourAngle === hourStartAngle) {
return "";
}
- if ((minuteAngle === correctHourAngle) && (hourAngle === correctMinuteAngle)) {
- return "Remember the hour hand is the short hand and the minute hand is the long hand";
- }
- else if ((minuteAngle === correctMinuteAngle) && (hourAngle !== correctHourAngle)
- && (hourAngle === roundToNearest(hourSnapDegrees, timeToDegrees(5 * HOUR)))) {
- return "Remember the hour hand needs to move over the course of the hour";
+ if ((minuteAngle !== correctMinuteAngle) || (hourAngle !== correctHourAngle)) {
+ if ((minuteAngle === correctHourAngle) && (hourAngle === correctMinuteAngle)) {
+ return "Remember the hour hand is the short hand and the minute hand is the long hand";
+ }
+ else if ((minuteAngle === correctMinuteAngle) && (hourAngle !== correctHourAngle)
+ && (hourAngle === roundToNearest(hourSnapDegrees, timeToDegrees(5 * HOUR)))) {
@spicyj Owner
spicyj added a note

Shouldn't this be rounding down?

@beneater Owner

hmm, i suppose so; if someone makes this mistake, they would probably round down

@beneater Owner

though actually timeToDegrees(5 * HOUR) only considers the hour, so I think this is working fine.

@spicyj Owner
spicyj added a note

So then what does roundToNearest do here?

@beneater Owner

Avoid floating point weirdness perhaps? Either that or nothing at all...

@beneater Owner

Yep.. adding:

console.log(hourAngle);
console.log(timeToDegrees(5 * HOUR));

resulted in:

30
30.000000000000004
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ return "Remember the hour hand needs to move over the course of the hour";
+ }
+ return false;
}
- return (minuteAngle === correctMinuteAngle) && (hourAngle === correctHourAngle);
+ return true;
</div>
<div class="show-guess">
minutePoint.moveTo(guess[0][0], guess[0][1], true);
Please sign in to comment.
Something went wrong with that request. Please try again.