R
Reactiflux

help-js

Deepak – 15-39 Aug 27

DDeepak8/27/2022
Hi, I'm unble to discrible but i need something like this insted of country.currency.symbol, i need country.USD.symbol. i want to have currency value and not as key beacuse every currency has different name in database.
UUUnknown User8/27/2022
2 Messages Not Public
Sign In & Join Server To View
DDeepak8/27/2022
this is the object that i need to access
"currencies": {
"PEN": {
"name": "Peruvian sol",
"symbol": "S/ "
}
},
"currencies": {
"PEN": {
"name": "Peruvian sol",
"symbol": "S/ "
}
},
@Timotius
UUUnknown User8/27/2022
2 Messages Not Public
Sign In & Join Server To View
DDeepak8/27/2022
no inside currencies you see "PEN"
UUUnknown User8/27/2022
Message Not Public
Sign In & Join Server To View
DDeepak8/27/2022
this change for every country so i can't hard code it
UUUnknown User8/27/2022
Message Not Public
Sign In & Join Server To View
DDeepak8/27/2022
here is my code
{Object.keys(country.currencies).map(
(currency, index) => {
return (
<span
key={index}
className="bg-lime-600 text-white px-1 rounded m-1"
>
{currency}
</span>
);
}
)}
{Object.keys(country.currencies).map(
(currency, index) => {
return (
<span
key={index}
className="bg-lime-600 text-white px-1 rounded m-1"
>
{currency}
</span>
);
}
)}
this gives me "PEN" but i want to go deeper and access symbol
UUUnknown User8/27/2022
Message Not Public
Sign In & Join Server To View
DDeepak8/27/2022
in the above example i have currency as key but i am looking for way that i can access the value of currency and not as key if i do PEN.symbol it works but if i do currency.symbol it says undefined i don't know how to define this problem so i can google it
UUUnknown User8/27/2022
2 Messages Not Public
Sign In & Join Server To View
DDeepak8/27/2022
wait, i found the solution console.log(country.currencies[currency].symbol); 💪
UUUnknown User8/27/2022
Message Not Public
Sign In & Join Server To View
DDeepak8/27/2022
i can't hard code pen. its different for every country for example for USA its USD
UUUnknown User8/27/2022
Message Not Public
Sign In & Join Server To View
DDeepak8/27/2022
🧐 yes, problem is solve. 90% time it is solved as i explain it to others 😀 so your help count 🙏 by the way, can i reach you future if you are active on discord
UUUnknown User8/27/2022
2 Messages Not Public
Sign In & Join Server To View
DDeepak8/27/2022
okay, i willl just ask in reactiflux thanks
UUUnknown User8/28/2022
Message Not Public
Sign In & Join Server To View

Looking for more? Join the community!