0

Noon or Midnight Pro Practice (Logical or Boolean Operators) pro-challenge may be broken.

Hello, -Neither of these codes solve for the AM/PM solution on SoloLearn, but they work out on Chrome (they appear to work on other portions of SoloLearn playground, but not on this particular challenge). -Please try them in that section if you don't believe me. function main(hour){ if (hour >= 0 && hour<=12){ return "am"; }else{ return "pm"; } } console.log(main(12)); //Fail-Returned "am". function main(hour){ if(hour >= 0 && hour <= 12){ return "am"; }else if (hour >=13 && hour <=24{ return "pm"; else{ return "NG"; } } console.log(main(12));//returns positive for 12 but negative for 14, and then positive for 14 and negative for 12.

8th Feb 2021, 10:32 PM
tristach605
tristach605 - avatar
5 Answers
+ 1
Thanks:). any other ideas (it really shoukld work)?
11th Feb 2021, 3:00 AM
tristach605
tristach605 - avatar
0
12 o’ clock is PM. it should be hour<12 had plenty of practice with this problem myself... 😁😅
10th Feb 2021, 2:18 PM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
Thanks, Wilbur Jaywright, -Did you mind sharing the code you used to pass this challenge? -The instructions (below) say that 12 should be "am", but not for 14? -"Given a clock that measures 24 hours in a day, write a program that takes the hour as input. If the hour is in the range of 0 to 12, output am to the console, and output pm if it's not. Sample Input 13 Sample Output pm" function main(hour){ if (hour >= 0 && hour <=12){ return "am"; }else{ return "pm"; } } console.log(main(12)); //now passes 12 as "am". console.log(main(14));//but fails 14 as expected "pm", actual "am"?
11th Feb 2021, 2:49 AM
tristach605
tristach605 - avatar
0
this is possibly a python to english terminology problem, as tuple(range(12)) returns the numbers from 0 to 11, which is 12 numbers. range(0, 12) does the same. in python, a range does not include the stopping point, thus “in the range of 0 to 12” means that 12 qualifies as PM, despite the appearance.
11th Feb 2021, 2:56 AM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
well, the hour should probably never come back negative...
11th Feb 2021, 3:01 AM
Wilbur Jaywright
Wilbur Jaywright - avatar