JavaScript: Reduce, an example. Thanks to Christian Johansen.