title: socket.username keeps displaying as udefined on my clinet html
body: <p>I am trying to build a chatroom in node.js and socket.io but when i try to display the users name beside their message it just shows undefined here is my client code </p>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta name="viewport" content="width=device-width"/&gt;
  &lt;meta name="description" content="BillIsChill-2.0 BETA"&gt;
  &lt;meta name="keywords" content="billischill,Bill,is,chill,2.0,billischill-2.0,gamer-chat,BillIsChill-Underground-Chat,BILLISCHILL,&gt;
  &lt;meta name="author" content="Nik Hendricks"&gt;
  &lt;script src="http://code.jquery.com/jquery-1.11.1.js"&gt;&lt;/script&gt;
  
      &lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt;
      &lt;title&gt;BillIsChill-2.0&lt;/title&gt;
      &lt;link type="text/css"  rel="stylesheet" href="http://billischill.ddns.net/billischill-2.0/css/masterStyle.css" /&gt;
      &lt;link type="text/css"  rel="stylesheet" href="http://billischill.ddns.net/billischill-2.0/css/animate.css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="main-header-div"&gt;
        &lt;p id="main-header-div-text"&gt;BillIsChill-2.0&lt;p&gt;
          &lt;form&gt;
              &lt;input id="main-header-div-search-txtinpt" class="search" placeholder="Search" name="search"/&gt;
          &lt;/form&gt;
      &lt;/div&gt;
        &lt;div id="sidebar-controls-div"&gt;
             &lt;div id="sidebar-homebutton"&gt;
                       &lt;div class="sidebar-control-img" id="sidebar-homebutton-img"&gt;
                       &lt;/div&gt;
             &lt;/div&gt;
                        &lt;div id="Chatrooms-sidebar-button" class="sidebar-control-button"&gt;
                          &lt;div class="sidebar-control-img" id="sidebar-chatroombutton-img"&gt;
                          &lt;/div&gt;
                       &lt;/div&gt;
                     &lt;div id="avatar-sidebar-button" class="sidebar-control-button"&gt;
                          &lt;div class="sidebar-control-img" id="sidebar-avatarbutton-img"&gt;
                          &lt;/div&gt;
                     &lt;/div&gt;
  
          &lt;/div&gt;
  
  
       &lt;div id="chat-rooms-div" class="main-div"&gt;
              &lt;div id="rooms"&gt;
              &lt;/div&gt;
       &lt;/div&gt;
       &lt;div id="chat-box-div" class="main-div"&gt;
       &lt;div id="chatlog-display-div"&gt;
  
      &lt;/div&gt;
      &lt;form id="chatform" action=""&gt;
          &lt;hr id="chat-box-div-hr"&gt;
          &lt;div id="chat-controls-div"&gt;
          &lt;input id="chat-box-div-txtinpt" class="big-txtinpt"type="text" spellcheck="false" placeholder="Message"&gt;
          &lt;input id="chat-box-div-submit" class="submit" type="submit" value="Send"&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  &lt;div id="online-users-div"&gt;
  &lt;div&gt;
      &lt;script&gt;
  
  
      var socket = io();
  
      socket.on('connect', function(){
          socket.emit('adduser', prompt("What's your name?"));
      });
      socket.on('updatechat', function (username, data) {
          $('#chatlog-display-div').append(username + data);
      });
      socket.on('welcomeuser', function(data, username){
          jQuery("#chatlog-display-div").append(data + username);
      });
      socket.on('updaterooms', function(rooms, current_room) {
          $('#rooms').empty();
          $.each(rooms, function(key, value) {
              if(value == current_room){
                  $('#rooms').append('&lt;div id="chatroom-box"&gt;&lt;center&gt;' + value + '&lt;center&gt;&lt;/div&gt;&lt;hr&gt;');
                  $("#chatlog-display-div").scrollTop($("#chatlog-display-div").prop("scrollHeight"));
              }
              else {
                  $('#rooms').append('&lt;div id="chatroom-box"&gt;&lt;center&gt;&lt;a id="chatroom-box-link" href="#" onclick="switchRoom(\''+value+'\')"&gt;' + value + '&lt;/a&gt;&lt;/center&gt;&lt;/div&gt;&lt;hr&gt;');
                  $("#chatlog-display-div").scrollTop($("#chatlog-display-div").prop("scrollHeight"));
              }
          });
      });
      function switchRoom(room){
          socket.emit('switchRoom', room);
      }
  
  
  
  
       $('form').submit(function(e) {
       e.preventDefault();
  
  
  
  
     //right here is were i started changin it
  
             //gets the value from the message text feild and sets it as the    message var
       var message = {
              text : $('#chat-box-div-txtinpt').val()
              }
          if (message.text.trim().length !== 0) {
                          socket.emit('chat-message',message);
                  //append the message to the chatlog-display-div
                  $('#chat-box-div-txtinpt').focus().val('');
                  jQuery("#chatlog-display-div").append('&lt;div&gt;&lt;b&gt;'+socket.username+':&lt;/b&gt;&amp;nbsp'+message.text+'&lt;/div&gt;&lt;hr&gt;');
                              $("#chatlog-display-div").scrollTop($("#chatlog-display-div").prop("scrollHeight"));
              }
                          });
            socket.on('chat-message', function (message) {
             jQuery("#chatlog-display-div").append('&lt;div&gt;&lt;b&gt;'+socket.name+':&lt;/b&gt;&amp;nbsp'+message.text+'&lt;/div&gt;&lt;hr&gt;');
                           $("#chatlog-display-div").scrollTop($("#chatlog-display-div").prop("scrollHeight"));
            });
  
                var something = document.getElementById('sidebar-homebutton');
  
                something.style.cursor = 'pointer';
                something.onclick = function() {
                window.location.href = "http://billischill.ddns.net";
  
                 };
  
      &lt;/script&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>and here is my server code </p>
  
  <p>index.js</p>
  
  <pre><code>var mysql = require("mysql");
  var app = require('express')();
  var http = require('http').Server(app);
  var io = require('socket.io')(http);
  var usernames = {};
  var rooms = ['General-Chat','Tech-Chat','Gamer-Chat',"BillIsChill-Underground-Chat","Programer-Chat","Hacker-Chat","Minecraft-Chat","Gta-Chat","Misc-Chat","Current-Events-Chat"];
  
  
  
  app.get('/', function(req, res){
    res.sendfile('index.html');
    //res.sendfile('/login/');
  });
   http.listen(8080, function(){
    console.log('listening on *:8080');
  });
  
  var con = mysql.createConnection({
      host: "localhost",
      user: "root",
      password: "password",
      database: "messages"
   });
   io.on('connection', function (socket) {
      socket.on('adduser', function(username){
      socket.username = username;
      socket.room = 'General-Chat';
      usernames[username] = username;
      socket.join('General-Chat');
      socket.broadcast.to('General-Chat').emit('updatechat', '&lt;b class="servertxt"&gt;SERVER: &lt;/b&gt;', socket.username + ' has connected to this room' + '&lt;hr&gt;');
      socket.emit('welcomeuser', '&lt;b class="servertxt"&gt;SERVER:&lt;/b&gt; Welcome ', socket.username + '&lt;hr&gt;');
      socket.emit('updaterooms', rooms, 'room1');
  });
  socket.on('switchRoom', function(newroom){
    socket.leave(socket.room);
    socket.join(newroom);
    socket.emit('updatechat', '&lt;b class="servertxt"&gt; SERVER &lt;/b&gt;', 'you have connected to '+ newroom + '&lt;hr&gt;');
    // sent message to OLD room
    socket.broadcast.to(socket.room).emit('updatechat', '&lt;b class="servertxt"&gt;  SERVER &lt;/b&gt;', socket.username+' has left this room &lt;hr&gt;');
    // update socket session room title
    socket.room = newroom;
    socket.broadcast.to(newroom).emit('updatechat', '&lt;b class="servertxt"&gt; SERVER &lt;/b&gt;', socket.username+' has joined this room &lt;hr&gt;');
    socket.emit('updaterooms', rooms, newroom);
   });
    console.log('a user connected');
    socket.on('disconnect', function(){
      // remove the username from global usernames list
      delete usernames[socket.username];
      // update list of users in chat, client-side
      io.sockets.emit('updateusers', usernames);
      socket.leave(socket.room);
  });
    socket.on('chat-message', function (message) {
       console.log('message:', socket.username+': ' + message.text);
  
   var insert = { roomName: socket.room, username: socket.username, message: message.text };
  
   //puts message in db
   con.query('INSERT INTO messages SET ?', insert, function(err,res){
    if(err) throw err;
  
    console.log('Last insert ID:', res.insertId);
  });
   //excludes "socket" from getting the emit
        socket.broadcast.to(socket.room).emit("chat-message", message);
    });
  });
  </code></pre>
  
  <p>Can somone please help me  i am very confused on what is happening here</p>