-
-
Save craigzour/408e390d24b113898fa014c7fc5af029 to your computer and use it in GitHub Desktop.
ex1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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