Can you put in logic in a literal string?
1 min readJan 30, 2020
You bet, you can!
console.log(`The time right now is ${new Date().getHours() > 12 ? new Date().getHours() : new Date().getHours()} hours`)// The time right now is 22 hoursconsole.log(`The time right now is ${new Date().getHours() > 12 ? new Date().getHours() - 12 : new Date().getHours()} ${ new Date().getHours() > 12 ? `PM`: `AM`} `)// The time right now is 10 PM