Completed reduce.js from Eloquent Javascript