Seven years, but I tought I could help anyone else that comes across a similar problem. For example, if you want to use JQuery's $.each() with .append() to make an list of users, such as:
Here's what you DON'T want to do:
element.append(``);
$.each(users, function(key, value) {
element.append(`- ${value.name}
`);
});
element.append(`
`);
The output will be something like:
User 1
User 2
Instead, here's what you WANT to do:
element.append(``);
$.each(users, function(key, value) {
$("#ul-users").append(`${value.name}`);
});
So the output will be as follows: