JSFiddle - React, Tailwind, and code Playground
JavaScript
var jsonsymbols= {"id9":"WFC","id8":"MSFT","id7":"BRK-A","id6":"SPY","id5":"F","id4":"AMZN","id3":"BABA","id2":"YHOO","id1":"GOOG","id0":"AAPL"};
// assume an unknown number of stock symbols..
var count = 0;
var outputPrices = {};
for (key in jsonsymbols) {
outputPrices['newid'+count]['price'] = get_price(jsonsymbols[key], count, function(){
console.log(" Dummy function");
});
count++;
}
console.log("\ncount = " + count);
console.log("\noutput = " + JSON.stringify(outputPrices));
function get_price(symbol, countindex, callback){
setInterval(function(){
// do nothing... The actual function makes a http call to another server
// and does stock price lookup. We can only look up one stock at a time,
// hence the repeated calls.
},1000);
return 124.12;
callback();
};