Complex keys – Hands on exercise

I have executed the following code in browser.

1localStorage["lists"] = JSON.stringify( "[1,2,3]" );
2localStorage["lists:1"] = JSON.stringify( {name: "Personal", order: 1} );
3localStorage["lists:2"] = JSON.stringify( {name: "Product", order: 2} );
4localStorage["lists:3"] = JSON.stringify( {name: "Code Project", order: 3} );
5localStorage["lists:1:todos"] = JSON.stringify( ["Pay bill", "Write next chapter"] );
6localStorage["lists:2:todos"] = JSON.stringify( ["Take photo of product"] );
7localStorage["lists:3:todos"] = JSON.stringify( ["Work on ABC module.", "Contact the client"] );

Now open the browser console and try to complete the following tasks.

  1. Push a new task "Sign contract" to Personal list.
  2. Create a new list named "Summer Project".

Note: To open console in Google Chrome

Method 1) Press F12 then select Console tab.

Method 2) Right click on empty space > Click Inspect Element > Console tab.

What’s next? We’re going to take a look at “Saving the book list”.

overlaied image when clicked on thumbnail

Makzan | Mobile web app dev with phonegap | Table of Content