Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function executeFindRentsByPriceCommand(minPrice, maxPrice) {
- if (isNaN(minPrice) || isNaN(maxPrice)) {
- throw new Error("Invalid price range.");
- }
- var selectedOffers = _offers.filter(function (offer) {
- return offer.getPrice() >= minPrice && offer.getPrice() <= maxPrice && offer instanceof RentOffer;
- });
- selectedOffers.sort(function (a, b) {
- // stable sort
- var result = a.getPrice() - b.getPrice();
- if (result == 0) {
- result = a.getEstate().getName().localeCompare(b.getEstate().getName());
- }
- return result;
- });
- return formatQueryResults(selectedOffers);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement