Is there a better way than using 2 for loops and 2 if statements deep?jsfiddle:https://jsfiddle.net/bobbyrne01/bmnk9bLz/Code:var documentsInDatabase = [{  id: '1',  revision: '1'}, {  id: '2',  revision: '1'}, {  id: '3',  revision: '1'}];// incorrect revision of document with id of 1, and non-existent document of id 4var requestedDocuments = [{  id: '1',  revision: '2'}, {  id: '4',  revision: '1'}];var result = {  ids_not_found: [],  revision_mismatches: []};// 4 nested blocks deepfor (var i = 0; i < documentsInDatabase.length; i++) {  for (var j = 0; j < requestedDocuments.length; j++) {    if (documentsInDatabase[i].id === requestedDocuments[j].id) {      if (documentsInDatabase[i].revision !== requestedDocuments[j].revision) {        result.revision_mismatches.push(requestedDocuments[j].id);      }      requestedDocuments.splice(j, 1);      break;    }  }}for (var l = 0; l < requestedDocuments.length; l++) {  result.ids_not_found.push(requestedDocuments[l].id);}document.getElementById('container').innerHTML = JSON.stringify(result, null, 2);
Determine if requested documents exist and if they do, whether they match requested revision number
javascript