Arithmetic problem generator based on parameters. To be used for ditto sheets.
Generates random addition and subtraction based on parameters.
Let’s import the following.
import { Problem } from './models/Problem';
import { Operand } from './models/Operand';
Now let’s add two numbers:
let problem = new Problem(
"+",
[
new Operand(1, 5),
new Operand(4, 6)
]
);
// Return something like "3+4"
console.log(p.generateExpression());
// Returns 7
console.log(p.getAnswer());
// Returns -1
console.log(p.getSubtraction());
// Returns 7
console.log(p.getSum());
Currently tests are limited. Uses Jasmine to test.
Installing Jasmine for TypeScript:
# Global Jasmine installation
npm install -g jasmine
# TypeScript Jasmine types
npm install --save @types/jasmine
To run the tests:
npm test
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.