-1

What does the following function mean in JavaScript

let Kim =(hour >= 12)? " PM ":" AM ";
console.log(Kim);
flyingfox
  • 13,414
  • 3
  • 24
  • 39

1 Answers1

-1

It's a ternary conditional operator - if the hour variable is at least 12, return "PM" otherwise return "AM".

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator

Leaderboard
  • 371
  • 1
  • 10
  • It's a conditional operator, not a comparison operator. It isn't a function so it doesn't return anything. And this is a FAQ with many duplicates that doesn't need another answer: [avoid trying to answer questions which... ...have already been asked and answered many times before.](https://stackoverflow.com/help/how-to-answer) – Quentin Oct 07 '22 at 06:55