Is there a simpler way to retrieve an object property in JavaScript using a variable?
The following method does not work:
var element_id = this.data().element_type + 'id';
Instead of the above, here's a more streamlined approach:
var element_id;
if ( element_type == 'assignment' ) {
element_id = this.data().assignmentid;
} else if ( element_type == 'question' ) {
element_id = this.data().questionid;
} else {
element_id = this.data().answerid;
}