Concepts

Domain calculation contract

Try the free JavaScript compiler

Keep a business calculation independent of the UI or transport.

Formal Syntax & Structure

javascript syntaxjavascript
calculate(input) → result

Working Example

Example Snippetjavascript
(async () => {const total=({qty,unit})=>qty*unit;const format=n=>`${n} credits`;console.log(total({qty:3,unit:4}),format(total({qty:0,unit:4})));})()
JavaScript Reference