Storing an array value into an array value with no repeat value

Hello,

let array = [];
setInterval(function() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
	if (this.readyState == 4 && this.status == 200) {
		var myObj = this.responseText;
        snifferOnServer(myObj);

	}
};
xhr.open("GET", "http://i have hide this /wifimac", true);
xhr.send();

}, 1000);



let array = [];
function snifferOnServer(x) 
{

    let obj = x.split(']');
    //console.log(obj);
    for (let i = 0; i < obj.length; i++) {
        mac = obj[i];
        macIdData = mac.split(",");
        console.log(macIdData);

        array = [...array, [macIdData]];
    }
    


}

So in the program, I am getting a string of values from a server, and it looks like this:

403D,55,59]42348,55,58]4C85,56,58]

So I have used the split function to separate every set of data.

As you can see, myObj is constantly receiving data, which I need to store in an array so that I can display it on an HTML page later. So after I again split and target ", " now data look like this
Capture

And then I started storing values in array = [...array, [macIdData]];

But the problem is that macIdData contains a repeated value, which I don’t want to store in that array as you can see in image i have consoled a output of macIdData . So This value is getting stored in an array .

this data contains mac|ttl(time to leave) | status/time

So I need to create logic. If I check if Mac exists on that array, if yes, I only need to update the other value, for example.

403D,55,59
//mac ,ttl,status

If above mac already exists on the array, I will just overwrite the other two columns with a new value which is ttl status

Thank You

Use an object.

data = {}

//new data in;
data[newdata[0]] = [newdata[1],newdata[2]]

image

(heck if you wanna be fancy, make the two item array another object)
data[newdata[0]] = {"ttl":newdata[1], "status":newdata[2]}