Adding a jQuery to add the users to the list

First up let's go ahead and make a new jQuery element. We're going to make a variable called ol. This is going to store a new element using jQuery. We're going to create an ordered list. We'll create that ol tag:

socket.on('updateUserList', function(users){
  var ol = jQuery('<ol></ol>');
});

Now we need to iterate over every user doing something with that user, users.forEach is going to let us get that done. We're going to pass in our function and inside of that function we can add the individual user:

socket.on('updateUserList', function(users){
  var ol = jQuery('<ol></ol>');
    
  users.forEach(function () {
          
  });
});

The argument for the function is the name, the user string, and all we're going to do ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.