Greetings to all! I will go straight to the point.

I am using node.js engine to write javascript code and debug. I have created a map with some values and I want to use the key_value content passed to the function to call a value from this map.

Ideally:
E.g., If key_value= "age"
return Students["Mark"].age


Originator.prototype.student= function(originator_name, key_value){ // key_value="age"
var Students = {
"Mark": {
age: 23,
hair_color: "brown",
height: 1.78
},
"Tom": {
age: 19,
hair_color: "black",
height: 1.74

},
"Nick": {
age: 26,
hair_color: "blonde",
height: 1.78
}
};

var operator = Students["Mark"];
return operator.key_value; // where key value can be age.
};

I tried print out the Node.js global function below to convert the string "age" to a variable and use it as a key:

console.log(Students["Mark"].global[key_value]);

but I get this error:

console.log(Students["Mark"].global[key_value]);
^
TypeError: Cannot read property 'age' of undefined.

Does anybody know how to do this?