Math Expression Generator
JavaScript library to compute random arithmetic expressions (of configurable length) that evalute to a given number.
Usage
; const expression = ; console; // [15, '+', 5] const longExpression = ; console; // [ 2, '*', 13, '*', 10, '*', 1207, '/', 65 ]
Evaluate the expression
If you want to evaluate the returned expression (to verify it is correct, for example), you can use mathjs (but there are plenty of other library solutions out there):
;; const expression = ; const result = math; console; // 20
Documentation
Generated with typedoc ❤️
TypeScript Types
If you are using TypeScript in your own project, you can import some types from this library.
Expression:
import Expression from 'math-expression-generator/types/Expression';
Operator:
import Operator from 'math-expression-generator/types/Operator';