Skip to content

Instantly share code, notes, and snippets.

@craigzour
Last active September 9, 2022 12:39
Show Gist options
  • Save craigzour/408e390d24b113898fa014c7fc5af029 to your computer and use it in GitHub Desktop.
Save craigzour/408e390d24b113898fa014c7fc5af029 to your computer and use it in GitHub Desktop.
ex1
const formResponses = [{Status: "New", CreatedAt: 1662477251}, {Status: "Saved", CreatedAt: 1662477251}];
const results = formResponses.reduce((acc, current) => {
if (responseAge > 13) { // responseAge is defined using the same day diff logic that can be found in the previous phase
if (current.Status === "New") {
return { ...acc, NumberOfUnsavedResponsesBeyond13Days: acc.NumberOfUnsavedResponsesBeyond13Days + 1 };
} else if (current.Status === "Saved") {
return { ...acc, NumberOfUnconfirmedResponsesBeyond13Days: acc.NumberOfUnconfirmedResponsesBeyond13Days + 1 };
}
}
return acc;
}, { NumberOfUnsavedResponsesBeyond13Days: 0, NumberOfUnconfirmedResponsesBeyond13Days: 0 });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment