I have two arrays:
//list elements from html
var list = document.querySelectorAll('#pres-list-ul li');
//list of retrieved objects from api
var objects = self.retrievedItems;
The contents of list is saved on a html file for efficiency (no need to re-render same data unless you refresh)
I want to remove a list item from the html if it doesn't exist anymore in the retrieved objects.
I know it is somewhere along the lines of the code below but I couldn't work it out.
//I need to compare the id? For that another loop - which will run hundreds and thousands of time?
for(var j = 0; j < objects.length; j++) {
if(objects.indexOf(list[i]) === -1) {
//false
} else {
//true
}
}
Scenario:
list: 57 //local
objects: 56 //online
Find that extra value in list and remove it.
List:
<li id="item-5756" data-category="" data-group="" data-created="" data-author=""></li>
Object:
0: {
id: //
title: //
description //
// ...
}
1: {
//...
}