how to write else and if in javascript code example
Example: javascript if else
/* Shorten if-else by ternary operator*/
const go = "yes"
let race = null
race = go === "yes" ? 'Green Light' : 'Red Light';
/* Shorten if-else by ternary operator*/
const go = "yes"
let race = null
race = go === "yes" ? 'Green Light' : 'Red Light';