Stock exchange scenario in JavaScript:

"use strict";

var A, B, C, trade;

A = {query:"buy",price:40,units:100};

B = {query:"sell",price:41,units:200};

C = {query:"sell",price:40,units:75};

Why was the offer taken?

And how can he still have 40 up to buy for 25?

Did both party agree on it?

It seem to me that ones the price is match, it didn't matter the unit in question.