function getObjects(obj, key, val, newVal) { for (var i in obj) { if (!obj.hasOwnProperty(i)) continue; if (i == key && obj[key] == val) { obj[key] = newVal; } } return obj }