Predict JSON.parse with Nested Data
Predict Output Easy
Question
What does this code print?
Code
const json = '{"user":{"name":"Grace","skills":["JS","CSS"]}}';
const data = JSON.parse(json);
console.log(data.user.skills[0]);
Hint
Navigate through the nested structure step by step.
Explanation
JSON.parse converts the JSON string into a nested JavaScript object. data.user is the inner object, data.user.skills is the array ["JS", "CSS"], and data.user.skills[0] is "JS". The nested structure mirrors the JSON exactly.
Related Resources
Related Lessons
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.