daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function pad(n) {
  2.       return n.toString().length === 1 ? `0${n}` : n;
  3.     }
  4.  
  5.     function serializeActivities(arr) {
  6.       const obj = {};
  7.       for (let i = 0, l = arr.length; i < l; i++) {
  8.         const thisDate = arr[i].updatedAt;
  9.         const day = pad(thisDate.getDate());
  10.         const month = pad(thisDate.getMonth() + 1);
  11.         const year = thisDate.getFullYear();
  12.         const key = [year, day, month].join('-');
  13.         obj[key] = obj[key] || 0;
  14.         obj[key]++;
  15.       }
  16.       return obj;
  17.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top