In this lab, we are going to play with the localStorage object. The user is going to be able to save, read and delete
key/value pair from the localStorage
- In your labs folder, open the web_storage folder and edit the script.js file
- In the code, look for a // TODO 1. What we need to do here is to save a key/value pair into the localStorage.
In this function, the key and the value entered by the user have been obtained (variables localKey and localValue)
- Look for a // TODO 2. What we need to do here is to remove a key/value pair from the localStorage using
the key. The key is passed to the function you are editing with the variable key
- Look for a // TODO 3. What we need to do here is to remove every key/value pair from the localStorage
- Look for a // TODO 4. Here we want to iterate over the key/value pairs using their index. Thanks to the index,
get the key of a key/value pair
- Look for a // TODO 5. Thanks to the key you have just got, get the value of the current key/value pair
- You should be done by now. Open index.html in a browser and try to add, see, and delete key/value pairs from
the localStorage
Files