0

I need help with a function I've created.

For example, I parse a JSON string and I want to get the value of the passed parameter from the parsed JSON.

function returnVal(name) {
  parsedJSON = JSON.parse('{"test": "hello"}');
  return parseJSON.name;
}
nnnnnn
  • 143,356
  • 28
  • 190
  • 232

1 Answers1

3

Try this:

return parsedJSON[name];
Ivan Chernykh
  • 40,230
  • 12
  • 130
  • 145