As you noticed in our project overview of the rule of the page, we still maintain the data, I mean
questions and final result of users, and it was because of local storage.
It's very easy to understand and use.
So I will briefly describe what local authorities and how to use it.
It is a built in memory space and a Web browser which holds permanently information about 100 megabytes.
And it's absolutely enough for our application.
Let's see, where can we find local storage in a Web browser that we need to open dev tools and then
go to application section?
And in storage part, we can find local storage.
Let's drop down it and it will have a place where our data will be stored.
The information which we will add here will be saved as key value pairs.
All right, let's go back to Brackett's.
We don't need this coats inside modules anymore, so let's delete them.
And also for each module, that's a right to comment, because when the amount of the code is increased,
it will be a little bit hard to find is part of the code without comments for modules.
I would like to use kind of different comments in order to clearly separate and find them.
Let's copy and paste for a second module and right here, UI controller, and then do the same for the
third module, which is controller.
OK, let's continue talking about like storage throughout the project.
We will need to use three main methods which are set item, get item and remove item.
In order to have access on local storage.
We need to write it with cavalcades.
And then in order to add the item we need to attach to it, set it a method using documentation.
This method holds two parameters.
As we said, the information is stored as key value pair.
So first parameter will be a key, which will be used then to gather information from local storage.
So right here, for example, data and remember that it should be always passed as a string.
As for the second parameter, which is the value we can pass for any data type we want, but when we
get it back, that type will be always transformed into string.
So let's pushier array.
Write the numbers from one to four.
So now this data is stored in local storage.
In order to see that, let's go to the browser, reload and you see the data with numbers.
In order to get back this data, we need to use another method, which is get item.
So that's right.
Cancel that look like a storage dot get item.
This method holds one parameter, which is key in our case, it's data.
So right here, data.
Then reload again and check the console.
You see that instead of an array, we have just numbers, actually, these numbers are represented as
a street value.
Let's prove that and check the type of the data right here type of operator.
Then again, reload and see that it's definitely a strain, actually, it's a problem for our application,
so we need somehow to avoid it for that.
There are two methods which will actually solve this problem.
First method is Jason doctrine.
If so, right here before Arae.
Jason Dart throwing if.
And surround the array with parentheses.
Let's go to Browsr and check again memory, go to application.
And without.
You see that now the value is a little bit different instead of just numbers.
Now we have them in square brackets, but if we check cons. still, we will have data type of the value
as string.
So in order to get the data, but with its original type, we need to use another method called Jason.
Don't pass it first.
Let's remove type of operator and then right.
Jason that pass.
Let's go to Browsr, reload, and that's what we wanted.
We got back an original.
All right, OK.
The next thing I want to show you is that if we insert other data using Sankei, then we will lose old
content and new data will be added to local storage.
It means that when we use the same key and add new items to storage, then we just overwrite them.
So that's duplicate this line and change it right into, for example, an object.
Then go to Browsr, reload.
And you said that we have an object, only Erra is deleted if we check the storage, we will see at
the new data instead of old content.
All right, the last thing that I want to show you is how to remove the information from local storage.
For that, there is another method called remove item, which holds one parameter.
It is a key of the data.
So that's right.
It's up to the set item methods, local storage that remove item.
And here are the parameter as data that a revote and you see that we have now data type here because
actually data is remote from the storage and get items returned null value.
Remember that if there doesn't exist, the data we always get.
Now let's check the storage and you see that it's empty.
All right.
Actually, that's what we need to know throughout building our project.
So let's go ahead.