Alarm timer

Hi all! Tell me what is the error? The number n is given. n minutes have passed since the beginning of the night. Determine how many hours and minutes the digital clock will show at the moment. The program should output two numbers: the number of hours (from 0 to 23) and the number of minutes (from 0 to 59). Please note that n can be greater than the number of minutes in a day.
let n = 1441;
let h = Math.floor(n/60);
let m = (n % 60);
if (h >= 24){
h = Math.floor(n/60)%12
}
console.log(h,m)
let n = 1441;
let h = Math.floor(n/60);
let m = (n % 60);
if (h >= 24){
h = Math.floor(n/60)%12
}
console.log(h,m)
6 Replies
ChooKing
ChooKing9mo ago
The modulo 12 calculation is probably the problem. The instructions specifically state that the hours can range from 0 to 23, which is European/military time. The modulo 12 is only for AM/PM time. It should be modulo 24.
Joao
Joao9mo ago
I think it shouldn't be used at all. The instructions specify that only two numbers should be used, representing hours and minutes. If n is greater than several days, it's irrelevant since the problem doesn't ask for days.
Jochem
Jochem9mo ago
also, it helps if you share your code in plain text instead of as a screenshot. It lets people run the code for themselves if they want to
Eighth
Eighth9mo ago
The problem is that when I enter 24, the timer does not display the correct one and the result does not pass the code validity test, but it does not pass with my code, although the results were the same
MarkBoots
MarkBoots9mo ago
With modulo 24 it should work. You don't even need the if statement, just add it to where you calc the hours Math.floor(n/60) % 24 If that doesn't work, please show the test and result (can be a schreenshot)
Eighth
Eighth9mo ago
Thank you very much everything works, he cursed at if