Skip to content

Instantly share code, notes, and snippets.

@itzsaga
Created June 13, 2017 04:18
Show Gist options
  • Select an option

  • Save itzsaga/29cc99da607fddff0b066553bf13e37d to your computer and use it in GitHub Desktop.

Select an option

Save itzsaga/29cc99da607fddff0b066553bf13e37d to your computer and use it in GitHub Desktop.
// With ES6 Template Literals
data.items.forEach(function (item) {
itemList = itemList.add(`<li><strong><a href='/items/${item['id']}'>${item['name']}</a></strong>
<ul>
<li>Rating: ${item['rating']}</li>
<li>Notes: ${item['notes']}</li>
</ul>`
)
})
// With newline slashes
data.items.forEach(function (item) {
itemList = itemList.add('<li><strong><a href="/items/' + item['id'] + '">' + item['name'] + '</a></strong> \
<ul> \
<li>Rating: ' + item['rating'] + '</li> \
<li>Notes: ' + item['notes'] + '</li> \
</ul>'
)
})
// Concatenation
data.items.forEach(function (item) {
itemList = itemList.add('<li><strong><a href="/items/' + item['id'] + '">' + item['name'] + '</a></strong>' +
'<ul>' +
'<li>Rating: ' + item['rating'] + '</li>' +
'<li>Notes: ' + item['notes'] + '</li>' +
'</ul>'
)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment