Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Array.prototype.first = function(propertySelector = obj => obj) {
return this.filter(propertySelector)[0];
};
function firstDemo(orders) {
const firstOrderAfterMarch = orders.first(order => order.orderDate >= march);
printHeaderFooter(
"First order after March",
() => printOrder(firstOrderAfterMarch, indentBy),
indentBy
);
const firstOrderAfterSeptember =
orders.first(order => order.OrderDate >= september) || null;
printHeaderFooter(
"First or Default order after September",
() => printOrder(firstOrderAfterSeptember, indentBy),
indentBy
);
}
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.