/* function functionName(condition) { if(condition) { statement1 } else { statement2 } } */ function isRose(cat) { if(cat === 'rose') { return 'Hi, Rose. You are cute!' } else { return `Hi, ${cat}!` } } function isRose(cat) { if(cat === 'rose') { return 'Hi, Rose. You are cute!' } else if(typeof cat === 'string') { return `Hi, ${cat}!` } else { return 'Sorry. Please pass in a cat name.' } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter