Last active
November 12, 2017 15:13
-
-
Save aderaaij/a161dd205dfc8dfa0e111cc41afdeb47 to your computer and use it in GitHub Desktop.
In this template string we use a ternary conditional operator to only show the 'featured' part when it's available. If not available, the last part is omitted. From es6.io
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const song = { | |
name: 'Dying to live', | |
artist: 'Tupac', | |
featuring: 'Biggie Smalls' | |
}; | |
const markup = ` | |
<div class="song"> | |
<p> | |
${song.name} — ${song.artist} | |
${song.featuring ? `(Featuring ${song.featuring})` : ''} | |
</p> | |
</div> | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment