Chartjs-Using lodash to prepare data for "last day user registration" chart

1👍

You can create a defauls object with empty arrays and apply _.defaults:

var hours = _.range(0,24);
var defaultHours = _.zipObject(hours, _.map(hours, function(){return [];}));

_.defaults(grouped, defaultHours);

After that, grouped will hold the values you found, or empty array for hours that had no registrations.

Leave a comment