Skip to content

A small library that solves expressions step-by-step following the BODMAS principle.

License

Notifications You must be signed in to change notification settings

j0hnskot/calculate.js

Repository files navigation

calculate.js

A small library i created for a project that solves expressions step-by-step following the BODMAS principle.

It uses the js-expression-eval so be sure to grab it and include it in your html page else calculate.js won't work.

Not everything is implemented yet. Currently, the script can divide,multiply, add and substract while keeping in mind about brackets.

Beware! There are many bad practises included in the script. It was created in a hurry and it needs some clean up.

To use it :

Create a new calc object

var calc=new Calc();

Initialize the object's fields by passing the expression that needs solving

calc.init('2+5*3/1');

Do a step of calculation

calc.calculateStep();

or completely solve the expression

calc.solve();

The following contain the information generated from the library:

Contains every state of the expression, as the steps go on:

calc.expressionStates

Contains every answer of each calculation

calc.answers

It holds the answer of the current solving step

calc.currentAnswer

Documentation

Check here for more details

License

calculate.js is released under the MIT License.

About

A small library that solves expressions step-by-step following the BODMAS principle.

Resources

License

Stars

Watchers

Forks

Packages

No packages published