Answer the question
In order to leave comments, you need to log in
How do I get 2 elements out of an array while specifying another element in the same array?
{"exchangeRate":{"baseCurrency":"UAH","currency":"EUR","saleRateNB":18.7949200,"purchaseRateNB":18.7949200,"saleRate":20.0000000,"purchaseRate":19.2000000},{"baseCurrency":"UAH","currency":"GEL","saleRateNB":8.1500890,"purchaseRateNB":8.1500890},{"baseCurrency":"UAH","currency":"PLZ","saleRateNB":4.4922010,"purchaseRateNB":4.4922010,"saleRate":5.0000000,"purchaseRate":4.2000000}]}
saleRate
and purchaseRate
. Answer the question
In order to leave comments, you need to log in
const rawObject = {
exchangeRate: [
{
baseCurrency: 'UAH',
currency: 'EUR',
saleRateNB: 18.7949200,
purchaseRateNB: 18.7949200,
saleRate: 20.0000000,
purchaseRate: 19.2000000
},
{
baseCurrency: 'UAH',
currency: 'GEL',
saleRateNB: 8.1500890,
purchaseRateNB: 8.1500890
},
{
baseCurrency: 'UAH',
currency: 'PLZ',
saleRateNB: 4.4922010,
purchaseRateNB: 4.4922010,
saleRate: 5.0000000,
purchaseRate: 4.2000000
}
]
};
const euro = rawObject.exchangeRate.find(obj => (obj.currency === 'EUR'));
console.log(euro);
console.log(`Euro saleRate: ${euro.saleRate}`);
console.log(`Euro purchaseRate: ${euro.purchaseRate}`);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question