sharpimge
1/13/2020 - 4:53 AM

Examples of Template Literal/Strings in JS

// With Template Strings (ES6)
// Different examples below like functions, conditional, etc (hello, 2+2,and so on)

html = `
		<ul>
			<li>Name: ${name}</li> 
			<li>Age: ${age}</li>
			<li>Job: ${job}</li>
			<li>City: ${city}</li>
			<li>${2 + 2}</li>
			<li>${hello()}</li>
			<li>${age > 30 ? `Over 30` : `Under 30`}</li> 
		</ul>
		`;

document.body.innerHTML = html;