Accumulate without mutating the input
A running total starts at zero. Each loop iteration adds one amount. Keep the source array unchanged so another part of the application can reuse it. An empty array naturally returns zero.
Practise
Add a check that throws TypeError when any amount is not a finite number. Preserve the empty-array result.
Give me a hint
Number.isFinite(amount) is false for NaN, Infinity and strings. Validate before adding.
Remember: Validate values before arithmetic.
Project runtime and safety limits
JavaScript supports synchronous CommonJS modules: const helper = require('./helper.js'), module.exports = …, and require('./data.json'). Only exact flat project filenames are resolved. No npm packages, Node APIs, ES module imports, DOM or asynchronous application lifecycle are provided.
Python can import flat .py project files and read project data under /workspace. Runtime-created files disappear after each run and are not copied back to the editor. Debug captures only the entry code, not imported modules. Interactive input and production servers are not supported.
The opaque frame cannot access your account storage or application APIs. Required runtimes/packages download from jsDelivr; this is not unrestricted network access. Do not paste secrets. Startup is capped at 60 seconds, execution at 5 seconds, output at 200 lines/20,000 characters and trace at 350 events. Large allocations can still stress your browser; there is no guaranteed browser memory quota.
Use the separate SQL/TypeScript and scripts-disabled HTML/CSS panels below for those formats. Native toolchains, installed packages, full browser apps, mobile builds and deployment need a suitable external environment. Local exercise checks are practice feedback, not certification.