I need help with modifying the code below to only calculate the total payments that occurred within the last 24 hours (86400 seconds).
var addr = 't1QATR1DnhnrKEsv3tUvWzcjFHKEV4GPBZU',
data = [{
"name": "zelcash",
"pending": {
"blocks": [
"0000000cc8cb614f91c1f2cb97cce10c6fcbcc16a10ed9e209e03b3debafe56e:b7887996c1267949ffcd80773a6512e7df9cce392ba1f76c89f3b5fa974a0c91:99856:t1QATR1DnhnrKEsv3tUvWzcjFHKEV4GPBZU.Lana:1529254887651",
"00000005a9bf4d9b58d031c4868b14645e93a29fa057f3a02547c8cc70ad46e2:7e679e73247e724e707c485dc9111f981e2bf7f19814abadfa7cecfbb897b146:99735:t1QATR1DnhnrKEsv3tUvWzcjFHKEV4GPBZU.Del:1529240255922"
],
"confirms": {
"00000005a9bf4d9b58d031c4868b14645e93a29fa057f3a02547c8cc70ad46e2": "130",
"0000000cc8cb614f91c1f2cb97cce10c6fcbcc16a10ed9e209e03b3debafe56e": "9"
}
},
"payments": [{
// Payment data omitted for brevity
}]
}]
var totalAmount =
data[0].payments.
map(payment => payment.amounts). //get all amount object
map(amounts => amounts[addr]). //get amount from addr
filter(price => price). //filter undefined amount
reduce((first, second) => { //sum amount
return first + second;
});
totalAmount = totalAmount.toFixed(5);
console.log(totalAmount)