Skip to content

Commit

Permalink
fix last to slice uses
Browse files Browse the repository at this point in the history
  • Loading branch information
hejkal committed Dec 19, 2024
1 parent 9e6fd49 commit b6f19fd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client/js/campaigns/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function query() {
* @returns
*/
function cumulative(data) {
var moments = dateRange(data[0].date, data.slice(-1).date, 'days')
var moments = dateRange(data[0].date, data[data.length - 1].date, 'days')
var dateStrings = moments.map((m) => m.format('YYYY-MM-DD'))

var proto = {
Expand All @@ -48,7 +48,7 @@ function cumulative(data) {
}, dateDictionary)

return Object.values(dateDictionary).reduce((a, b) => {
var last = a.slice(-1)
var last = a[a.length - 1];
b.offsite_cents += last.offsite_cents
b.onetime_cents += last.onetime_cents
b.recurring_cents += last.recurring_cents
Expand Down

0 comments on commit b6f19fd

Please sign in to comment.