The error message is puzzling as it seems to indicate a problem with setting the 'mark' property of undefined:
TypeError: Cannot set property 'mark' of undefined
at /home/ubuntu/workspace/tests/app.js:194:36
at Layer.handle [as handle_request](/home/ubuntu/workspace/tests/node_modules/express/lib/router/layer.js:95:5)
...
The code snippet causing this error is:
for(var i = 0;i < req.body.numOfMethods;i++)
{
for(var x = 0;x< numOfParts[i];x++)
{
methodsArray[i][x].mark=parts[i][x].mark;
methodsArray[i][x].content=parts[i][x].content;
}
}
However, running the debugging code below produces the following output:
numOfParts[i] = 3
numOfParts[i] = 2
numOfMethods = 2
...
This output confirms that methodsArray[i][x].mark
is indeed being assigned values properly. Therefore, the source of the error remains unclear.
Here's where the arrays used in the code are defined:
var methodsArray=[[{mark:Number,content:String}]];
var numOfParts=[req.body.m1parts,req.body.m2parts,req.body.m3parts,req.body.m4parts];
...