I've a problem with this piece of code. I'm new in js and I don't understand why I only can print the latest pair each time I receive a new message throughout the websocket in the callback function. It prints "ethbtc" every time.
var hashtable = {};
var pairs= ['btcusd', 'btceur', 'eurusd', 'ethusd', 'etheur', 'ethbtc'];
for(var y=0;y<pairs.length;y+=1){
hashtable[pairs[y]] = {bid:0, ask:0, bidinusd:0, askinusd:0};
}
var pusher = new Pusher('de504dc5763aeef9ff52');
for(var y=0;y<pairs.length;y+=1){
var ob = pusher.subscribe('order_book');
var temp = pairs[y];
ob.bind('data', function (data) {
for(var i = 0; i < data.bids.length && i<=0; i += 1) {
console.log(temp);
}
for(var i = 0; i < data.asks.length && i<=0; i += 1) {
console.log(temp);
}
});
}