Twitch getJSON Question

Twitch getJSON Question
0.0 0

#1

the getJSON function seems to return the results of the array for channel names in a scrambled fashion.Which differs from the original order of the array.
I don’t see why this should be happening.
In all truth am a little lost with this project,could someone give me some suggestions please…
The second part of the code doesn’t seem to be working as it should either,thanks in advance.


#2

You should never expect the output to be in the same order as the array, since you’re dealing with asynchrony here. It’s true that the JSON requests are sent in order, but it takes time for the responses to arrive. Some responses will arrive faster than others, and those that arrive first will get displayed first. So don’t worry about it :wink:

(I think It’s possible to have them appear in order, but it’s more trouble than it’s worth IMO)


#3

yeah its ok I just misunderstood the way the forEach function worked

for example channel.forEach(myfunction);

where channel is the name of the array.

calls the function this is easy enough to understand,however the confusing bit was.
the myfunction itself comes with two bulit in arguments
myfunction(item,index);
so no need for iterators or the like.