- 2

Hello everyone, I want to solve an exercise Logical Operators in javascriptAnd I couldn't solve it, can you help me

Time flies when you’re having fun. 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() { var hour = parseInt(readLine(), 10); // Your code goes here }

23rd Jan 2022, 1:57 AM
slom slomi78
1 Odpowiedź
0
Use a if to compare...if (hour<= 12) { System.out.println("am"); } else { System.out.println("pm"); }
28th Jan 2022, 3:27 AM
Cristian Baeza Jimenez
Cristian Baeza Jimenez - avatar