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
  • 147,572
  • 30
  • 200
  • 241

1 Answers1

3

Try this:

return parsedJSON[name];
Ivan Chernykh
  • 41,617
  • 13
  • 134
  • 146