Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Add basic math operations to equations.js #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add basic math operations to equations.js
  • Loading branch information
embeddedt authored Apr 2, 2019
commit 87a3518cf8739366fe61ae69743c52b0b0667e82
16 changes: 16 additions & 0 deletions src/equations.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,20 @@ Equation.prototype._isCubic = function(variable) {
return this._maxDegree() === 3 && this._onlyHasVariable(variable);
};

Equation.prototype.subtract = function(val, simplify) {
return new Equation(this.lhs.subtract(val, simplify), this.rhs.subtract(val, simplify));
};

Equation.prototype.add = function(val, simplify) {
return new Equation(this.lhs.add(val, simplify), this.rhs.add(val, simplify));
};

Equation.prototype.multiply = function(val, simplify) {
return new Equation(this.lhs.multiply(val, simplify), this.rhs.multiply(val, simplify));
};

Equation.prototype.divide = function(val, simplify) {
return new Equation(this.lhs.divide(val, simplify), this.rhs.divide(val, simplify));
};

module.exports = Equation;