Created
December 23, 2017 22:15
-
-
Save ognjengt/e0e6735e149cd0254c3a6615be3266ac to your computer and use it in GitHub Desktop.
This file contains hidden or 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
async function getFinalResults(kNearest,nDays) { | |
var finalResults = []; | |
var finalResult = {}; | |
await forEach(kNearest, async(date) => { | |
var dateTime = new Date(date); | |
var pastDate = dateTime.toISOString().split('T')[0]; | |
var futureDate = new Date(date); | |
futureDate.setDate(futureDate.getDate() + nDays); | |
futureDate = futureDate.toISOString().split('T')[0]; | |
var valueForThatDay = this.coinDeskApiResults.bpi[pastDate]; | |
var valueForFutureDay = this.coinDeskApiResults.bpi[futureDate]; | |
finalResult = { | |
start: valueForThatDay, | |
end: valueForFutureDay | |
} | |
finalResults.push(finalResult); | |
}) | |
return finalResults; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment