I have this code where my "this.index" and "this.result" are undefined, how do I make it so that when I update their values it acts like pass by reference:
submitQuiz(addsMemberPoints, pointsCallback) {
this.getValues(this.answers, this.totalPoints, this.index, function(answers, totalPoints, ranks, index){
pointsCallback(answers, ranks, addsMemberPoints, totalPoints, index, function(index, points){
function getMember(obj) {
return Object.keys(obj).reduce(function(a, b){ return obj[a] > obj[b] ? a : b });
}
// would like to change index and result of initial class with new values
this.result = getMember(points);
this.index = index;
});
});
}
The error that is created is reproduced