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.
6 Réponses
+ 1
Thanks:). any other ideas (it really shoukld work)?
0
12 o’ clock is PM. it should be hour<12
had plenty of practice with this problem myself... 😁😅
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"?
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.
0
well, the hour should probably never come back negative...