For example say I have this function using the nodes classification :
function example(){
var exampleVar = nodes.classfication;
//below i use exampleVar to do calculations
.
.
.
.
}
but say sometimes i want to get the nodes status so I do this :
function example(){
var exampleVar = nodes.status;
//below i use exampleVar to do calculations
.
.
.
.
}
I dont want repeating code as (in my code) there is quite a lot of code in the function i want to reuse. So depending what I want to get out of this function ill pass it to the function like so :
function example(thisAttribute){
var exampleVar = nodes.thisAttribute; //using the variable passed to the function
//below i use exampleVar to do calculations
.
.
.
.
}
This doesn't work, how do I go about passing an object attribute as a parameter to a function ? I've tried looking online but I dont think Im searching for the correct things as I can't find anything to help. Thanks in advance anyway :)