Type a collection

Difficulty: Easy

TypeScript

Return the sum of finite numbers, or zero for an empty list.

Examples

[]0
[1, 2, 3]6
[-2, 0, 2]0

Constraints

Use strict TypeScript and a standalone function. No imports, packages, DOM, network, or file access. Inputs are JSON-compatible with at most 1,000 elements and 100,000 characters. Do not mutate inputs. Return the specified result rather than printing. Medium tasks combine narrowing and typed transformations.

Review lesson: Inference and explicit boundaries
TypeScript

Ready when you are

Write your solution, then run it against the practice tests.

Press Esc, then Tab to leave the editor. Code runs in an isolated browser workspace. Tests support learning, not verified grading.

Reset your code?

This replaces your current code with the starter and stops any running tests.