Created
March 31, 2018 18:20
-
-
Save dance2die/a33e3a0fbad62840fdba9ad70260aef1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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