What you’re seeing is not an issue with your JavaScript itself, but with Dreamweaver’s code editor syntax highlighting.
In particular, the editor currently struggles with template literals (strings wrapped in backticks `), especially when combined with arrow functions and embedded expressions. A line like:
const cartText = cart.map(item => `${item.id} x ${item.quantity}`).join("\n");
is perfectly valid JavaScript, which is why it works correctly in JSFiddle and in modern editors. However, Dreamweaver’s editor may misinterpret the backticks and lose track of bracket pairs, which then breaks the visual formatting and colouring of the code.
This is a known limitation of the editor, and the development team has already been informed. At the moment, it’s mainly a visual issue: the code still runs correctly, but the editor display becomes confusing.
The current workaround is to edit JavaScript files in an external editor such as VS Code or Sublime Text, and configure Dreamweaver to use it via Preferences -> File Types / Editors. Many developers use this setup for modern JavaScript syntax.
So to answer your question: your code is fine, and this is not a logic or syntax error on your side, but an editor limitation.
Hope this helps clarify what’s going on.