0

I have been trying to create a budget website I have written most of the code the problem here is that when I am trying to create an append my visual studio code editor detects the code as incorrect giving me these error messages. unterminated string literal. ts(1002), unexpected keyword or identifier. ts(1434), JSX expression must have one parent element. ts(2657) I have in my HTML file an unordered list as the parent element. here is my code. if anyone can help I would appreciate it

HTML

<h3 class="history">History</h3>
<ul class="list">
    <!--<li class="minus">
        Cash <span>-$400</span><button class="delete-btn">x</button>
    </li>-->
</ul>

Javascript

    const item = document.createElement('li');

    //Add class based on values

    item.classList.add(transaction.amount < 0 ? 'minus' : 'plus');

  item.innerHTML = '
  ${transaction.text} <span>${sign}${Math.abs(transaction.amount)}</span> <button class= "delete-btn" onclick= "removeTransaction"(${transaction.id})">x</button>
  ';

P.S. I am using this website to create it https://www.sourcecodeexamples.net/2020/12/expense-tracker-project-with-javascript.html.

jorge
  • 21
  • 5
  • If you're going to have multiline strings + interpolation, you need to use template literals. Also, there is an extra `"` character after `removeTransaction`. – Terry Jan 30 '22 at 17:40
  • 1
    Template literals use `\`` and not `'`. – CherryDT Jan 30 '22 at 17:43

0 Answers0