Predict localStorage Output
Predict Output Easy
Question
What does this code print?
Code
localStorage.setItem("name", "Ada");
console.log(localStorage.getItem("name"));
Hint
getItem retrieves the value that was set with setItem.
Explanation
localStorage.setItem("name", "Ada") stores the value "Ada" under the key "name". localStorage.getItem("name") retrieves it, returning "Ada". The value is always stored and retrieved as a string.
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.