Pls help
Logical or boolean operation "noon or night" exercise. Please teach me how to do it. https://www.sololearn.com/coach/419?ref=app 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 I tried many things but none worked so I need someone to help from scratch. process.stdin.setEncoding('utf-8'); let inputString = ''; process.stdin.on('data', inputStdin => { inputString += inputStdin; }); process.stdin.on('end', _ => { main(inputString); }); function main(input) { var hour = parseInt(input, 10) // Your code here //This is the provided base for the code }
10/8/2020 6:57:21 PM
Goutam Chaitanya
7 Answers
New Answer/*Just in case anyone wants to know, I completed it myself The answer is below*/ process.stdin.setEncoding('utf-8'); let inputString = ''; process.stdin.on('data', inputStdin => { inputString += inputStdin; }); process.stdin.on('end', _ => { main(inputString); }); function main(input) { var hour = parseInt(input, 10) // Your code here if(hour <=12){ console.log("am") } else{ console.log("pm") } }
Please show us a code you have started with and the linkto the challenge
my code here can help you: https://code.sololearn.com/ci0E8yhWAxVq/?ref=app
// i got the answer process.stdin.setEncoding('utf-8'); let inputString = ''; process.stdin.on('data', inputStdin => { inputString += inputStdin; }); process.stdin.on('end', _ => { main(inputString); }); function main(input) { var hour = parseInt(input, 10) var h = input var session = "AM"; if(h == 0){ session="am" } if(h > 12){ h = h - 12; session = "pm"; } console.log(session) }
The link is private other can't see. Description link is pro link.. Can't see Non-pro members.. So you need to copy paste description and your tried code, if you need.. Edit : Thanks for edit. You did it now..Goutam Chaitanya 👍👍👍