RPeraltaJr
12/6/2018 - 4:18 AM

Template Literals

The use of back-ticks (``)

// Example #1
const vegetableList = 
  `<ul>
    <li>Potato</li>
    <li>Onion</li>
    <li>Broccoli</li>
  </ul>`;

document.querySelector('.vegetables').innerHTML = vegetableList;


// Example #2
function like(thing) {
  return 'I like ' + thing;
}
function love(thing) {
  return `I love ${thing}`; 
}

const sentence = `<p>${like('apple')}, but ${love('oranges')}</p>`;
document.querySelector('.interpolation').innerHTML = sentence;