middle-match
v0.1.0
Published
Finds a price point overlapping between a min and max the buyer and seller have discreetly proposed.
Downloads
17
Readme
Middle-match
Finds a price point overlapping halfway between a min and max from both parties (buyer and seller).
Example
- Paul is selling his car for $10,000. is prepared to take a little less but wants the most for it he can get, range 8,000 - 15000
- Bill wants to buy Pauls car and has a budget of $13,000. Of course he wants the best bargin he can get; range 5,000 - 13,000
Middle-match finds the halfway point between what Paul is prepared to reduce his asking price to and what Bill is prepared to increase his bid to. Both without stepping outside of their ranges.
the resulting price is: $10,500
Install
npm install middle-match --save
Usage
var middle = require('middle-match');
var buyer = {
min: 5000,
max: 13000
};
var seller = {
min: 8000,
max: 15000
};
console.log(middle.match(buyer,seller));
Also try with rounding
console.log(middle.match(buyer,seller,true));
Testing
With Mocha and Chai run: npm test