Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

exchange rates towards USD

node v0.12.18
version: 1.0.3
endpointsharetweet
var rp = require("request-promise"); var jsonData = await rp("https://www.kimonolabs.com/download/6eg4dlkq?apikey=v3n5rBZStfZ0nAujuhRChstaiBkpEsaU&type=json&kimmodify=1"); var data = JSON.parse(jsonData);
var collection = data.results.collection1 collection.push({abbr: "MDL", code : "001", currency: "Moldavian Leu", index: "0", rate: "1", rates: "1", url: "https://www.bnm.md/en/content/official-exchange-rates"})
var _ = require("lodash"); var rates = module.exports.rates = function(){ var ratesInUSD = {}; var MDLUSD = 0; _(collection).forEach(function(item){ if(item.abbr === "USD") MDLUSD = item.rates; }); _(collection).each(function(item){ ratesInUSD[item.abbr] = item.rates / item.rate / MDLUSD; }).value(); return ratesInUSD };
Loading…

no comments

    sign in to comment