Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript template literals html

// Create our object
const person = {
    name: 'TopCoder2021',
    job: 'Software Developer,
    city: 'Los Angeles',
    bio: 'Tony is a really cool guy that loves to code!'
}

// And then create our markup:
const markup = `
 <div class="person">
    <h2>
        ${person.name}
    </h2>
    <p class="location">${person.city}</p>
    <p class="bio">${person.bio}</p>
 </div>
`;

document.body.innerHTML = markup
 
PREVIOUS NEXT
Tagged: #javascript #template #literals #html
ADD COMMENT
Topic
Name
4+2 =