If I understand correctly something like this should work:
Object.entries(testData).forEach(function (entry) {
if (actualObject[entry[0]] === entry[1].trim()) {
//answers match
} else {
//answers don't match
}
});
If you need to compare regardless of case then change entry[1].trim()
to entry[1].trim().toLowerCase()
.
EDIT:
Just to remind you that maybe you should add a check whether or not the values in the test data are null/undefined, if they are strings or not, etc.
solved To check the two array of object values based on the respective key?