I have the following problem to concat multiple object values into one Array!
My current code:
const coins = [];
Object.keys(prices).forEach((key) => {
coins.push(prices[key]);
console.log("prices", prices);
console.log("prices[key]", prices[key]);
console.log("coins", coins);
});
Output:
prices { ETH: { USD: 1332.03 }, BTC: { USD: 14602.09 } }
prices[key] { USD: 1332.03 }
coins [ { USD: 1332.03 } ]
prices { ETH: { USD: 1332.03 }, BTC: { USD: 14602.09 } }
prices[key] { USD: 14602.09 }
coins [ { USD: 1332.03 }, { USD: 14602.09 } ]
What needs to be achieved:
coins = [ 1339.64, 14617.95 ]
I only need the values to do mathematical operations with them.
coins.push(prices[key].USD);coins = [ 1339.64, 14617.95 ]you start with 1332.03 & 14602.09