I am newbie to the JavaScript world. I have a doubt how the return statement works in JavaScript.
What I am trying to do is to have a function pass one arguments
Try this:
function exampleFunction(param){
return exampleData[param];
}
EDIT: If you want to return null if the parameter is undefined, then take a look at Paul and Crazy Train's comments:
return (typeof exampleData[param] === 'undefined')? null: exampleData[param];
OR
return (param in exampleData) ? exampleData[param] : null;