I have two nested arrays and I need to get different values in to variable/array. For example: servicesCompare1[{serviceId: 112, name: services1},{serviceId: 113, name: services2}]
servicesCompare2[{serviceId: 113, name: services2}]
I need to get {serviceId: 112, name: services1} in to the variable.
I found many and many solutions but everyone I tried I got both of services. Not just that one I need. For example this: http://jsfiddle.net/WgykC/ ( I did it same, but still got value of servicesCompare1.)
My code:
self.services = ko.observableArray([]);
        self.lastCheck = ko.observable();
        var servicesCompare1 = [];
        var servicesCompare2 = [];
        $.getJSON("http://localhost:55972/api/status", function (data) {
            self.services(data.services);
            self.lastCheck = data.lastCheck;
            servicesCompare1 = data.services;
            servicesCompare2 = data.services;
        });
        function DashboardRefresh() {
            self.servicesRefresh = ko.observable([]);
            $.getJSON("http://localhost:55972/api/status", function (data) {
                servicesCompare2 = data.services;
                self.servicesRefresh(data.services);
            });
            if (servicesCompare2.length > servicesCompare1.length) {
                for (i = 0; i < servicesCompare2.length - servicesCompare1.length; i++) {
                    var ArrayIndexToAdd = servicesCompare2.length - 1 - i;
                    serviceToPush = servicesCompare2[ArrayIndexToAdd];
                    self.services.push(serviceToPush);
                }
            }
            else if (servicesCompare1.length > servicesCompare2.length) {
                var servicesToRemove = servicesCompare1.filter(a => !servicesCompare2.includes(a));
                console.log(servicesToRemove);
                console.log(servicesCompare1);
                console.log(servicesCompare2);
            }
        }
        setInterval(DashboardRefresh, 1000);
I don't understand what's the problem beacuse I think it should work...
