Skip to content

s0ftik3/Randomath

Repository files navigation

Randomath library

Just a simple JavaScript math library that creates random math examples of addition, subtraction, multiplication and division with fake answers and true ones.

Usage

const Randomath = require('randomath');
const math = new Randomath();

Methods

getRandomAdd(times) — returns a random addition example.

getRandomSubtract(times) — returns a random subtraction example.

getRandomMultiply(times) — returns a random multiplication example.

getRandomDivide(times) — returns a random division example.

getRandomCompare(times) — returns a random comparison example.

 

Output example of getRandomAdd method

[
  {
    example: '48 + 39',
    answers: [ 91, 87, 90 ],
    answer: 87,
    answerId: 1
  }
]

 

Default number of examples is one. You can change it by replacing times to the number of repeats you need. For example getRandomAdd(3) will return 3 addition examples.  

Each method returns an array of objects.

About

Just a simple JavaScript math library that creates random math examples of addition, subtraction, multiplication and division with fake answers and true ones.

Resources

License

Stars

Watchers

Forks