firstly i don't care about code effeicney and bets practise at the moment, only how variables work with arrow operators can some one explain why when one uses '=>' arrow operator within the code block it doesn't save or add to a variable already delate outside? I've tried 'var ttest;', 'var ttest={};', etc... how can I use something which is calculated or retrieved after the '=> {' on a global scale?
essentially what I need to do is to be able to add'{'Balance': balance,'price': price,'value': gbpvalue,'btcvalue': btcavlue};', to a global object and/or array or just use that info somehow out side:
'then(accounts => {...});'
let ttest;
client.rest.account.listAccounts().then(accounts => {
//console.log(accounts);
for (var item in accounts){
if (accounts[item]['currency'] == 'ETH'){
var balance = parseFloat(accounts[item]['balance']) + parseFloat(accounts[item]['hold']);
var price = parseFloat(apipriceReq('ETHGBP').price);
var gbpvalue = price * balance;
var btcavlue = (gbpvalue/(btcp / 100)/100);
ttest = {'Balance': balance,'price': price,'value': gbpvalue,'btcvalue': btcavlue};
}
}
});
//var ttt = client.rest.account.listAccounts();
console.log(ttest)