Callback function createListItem() is not working when I use it in map function. When I execute without the function its working as expected. Is there any thing I might have missed out?
// map func to loop the list
const allExpesneHTML = allExpenses.map(expense => {
createListItem(expense)
});
// join func to join strings and remove comma
const joinedAllExpenseHTML = allExpesneHTML.join("");
// console.log(allExpesneHTML);
expenseTableEl.innerHTML = joinedAllExpenseHTML;
// //Listen to click event
element.addEventListener("click", addExpenseToTotal, false);
// view layer
function createListItem({
desc,
amount
}) {
return `<li class="list-group-item d-flex justify-content-between">
<div class="d-flex flex-column">${desc} <small class="text-muted">March 11, 2021</small></div>
<span class="px-5">${amount}</span>
<button type="button" class="btn btn-outline-danger btn-sm"><i class="fas fa-minus-circle"></i></button>
</div>
</li>`;
}