Skip to content

Latest commit

 

History

History
66 lines (46 loc) · 1.12 KB

README.md

File metadata and controls

66 lines (46 loc) · 1.12 KB

Math Problem Generator

Generates random addition and subtraction based on parameters.

Usage

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());

Testing

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

Contributing

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.

License

MIT