Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Array.prototype.count = function(predicate = obj => true) {
return this.filter(predicate).length;
};
function countDemo(orders) {
const march = new Date(2018, 3, 1);
const ordersOnAndAfterMarch = orders.filter(
order => order.orderDate >= march
);
printOrders(ordersOnAndAfterMarch, (indentBy = 4));
const orderCountPlacedOnAndAfterMarch = orders.count(
order => order.orderDate >= march
);
WriteLine(
`Total Orders Placed On and After March: ${orderCountPlacedOnAndAfterMarch}`
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.