I'm fetching data from an API which returns currency exchange rates like so:
{"EUR_USD":1.044136}
I was able to manipulate the fetched data using:
const rate = Object.values(data).splice(11,5);
which returns 1.044
However, my next problem comes when trying to parseFloat this object into a number.. for some reason it only returns the first digit so in case of "1.044" it'd convert it into "1".
How can I handle this ? I'm thinking to perhaps map thru the rate array and then parseFloat everything..?
const parsedRate = rate.map(i => i).parseFloat();
would this even work ?
ok guys - sorry for taking your time and I appreciate all your answers! but I had JSON.stringify on the string and that's what was causing the problem... SORRY!!!
data.EUR_USDrather than a strange splice call? Then it would already be a Number value...data.EUR_USDlike so: ```data.${currOne}_${currTwo}``` i think this might be the best solution tbh, but I still need to find a way to parseFloat everything