DEV Community

kaan
kaan

Posted on

Save function parameter to a global array incoming from socket.on in node.js .why it only save the last element of the data

    var corona = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]];

    var lastclient;


    socket.on("playedemitbuy", function (veri) {

     lastclient= veri.lastclient;

      console.log("writedata :"+lastclient);


      corona[lastclient][veri.playedbuy] = 5;

    console.table(corona); //why does it not print all incoming data ?


        });
Enter fullscreen mode Exit fullscreen mode

Top comments (0)