21.6k views
2 votes
Assign jsonData with the parsed value of the stringData variable. Then, assign 29 to the points property in jsonData and assign stringData with the stringified version of jsonData.

var stringData = '{ "name": "Michael Jordan", "height": { "ft": 6, "in": 6 }, "points": 25, "position": "Power forward" }';

1 Answer

1 vote

Answer:

The solution is written in JavaScript:

  1. var stringData = '{ "name": "Michael Jordan", "height": { "ft": 6, "in": 6 }, "points": 25, "position": "Power forward" }';
  2. var jsonData = JSON.parse(stringData);
  3. jsonData.points = 29;
  4. stringData = JSON.stringify(jsonData);

Step-by-step explanation:

Given the string data as in Line 1, we use the JSON parse method to convert the string data into JavaScript object (Line 2) and assign the parsed data to variable jsonData.

Next, use the dot syntax to access the points property of the jsonData and set the value of 29 to it (Line 3).

At the end, use JSON stringify method to stringify the jsonData and assign the output to stringData (Line 4).

User Alexandra Franks
by
3.4k points