I am getting an unexpected identifier error for the following function.
function merge (one, two) {
one.forEach(function(assign){
//////////this next line is throwing the error////////////
if (two.some(function(req) req.related == assign.rid)) {
if (one.some(function(iter) iter.rid == req.rid)) {
iter.quantity++;
} else {
one.push(req);
}
}
});
return one;
}
The function is intended to operate on an array of objects.
req:function(req) { req.related == assign.rid }merge()is called with example inputs. It's not obvious what would be valid input here beyond "arrays." But generally, the process of removing code, while retesting to make sure the error still crops up will, in cases like these, usually lets you find the error on your own in the first place. Kind of like a doctor poking a patient all over to figure out where it hurts.