user6867266 user6867266 - 2 months ago 8
Javascript Question

why is d3 each() function only iterating through first item in list?

For some reason, when I implement the d3 each() function it only acts upon the first item in an array. For example, in the following function, only the user ID of the first user in the array is alerted:

https://jsbin.com/hayedeh/edit?html,js

What am I missing here?

Answer

U can do forEach like this:

  users.forEach(function(user)
  {
    alert(user.userID);
  });
Comments