Pls help | Sololearn: Learn to code for FREE!

+1

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

-1

/*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") } }

+6

Please show us a code you have started with and the linkto the challenge

+5

my code here can help you: https://code.sololearn.com/ci0E8yhWAxVq/?ref=app

+5

// 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) }

+1

You added it now. Thank for edit. And you got it. Nice.

0

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 👍👍👍

0

Jayakrishna🇮🇳 that's why I wrote the question and the base code