text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
for the counter so we are going to set
5,037.53
4.29
the value of counter equal to zero for
5,039.18
5.37
example and so now what needs to change
5,041.82
4.35
I'll go ahead and get rid of the
5,044.55
3.33
interval so that it only happens when I
5,046.17
3.6
click on it but what should this count
5,047.88
4.44
function actually do well first let me
5,049.77
5.37
get the value of the counter counter is
5,052.32
5.79
going to be whatever local storage get
5,055.14
5.67
item counter is I'm gonna get the
5,058.11
5.37
counter out of local storage I'm going
5,060.81
5.31
to increment it counter plus plus we'll
5,063.48
4.89
go ahead and set the value of this h1
5,066.12
3.51
elements innerhtml
5,068.37
3.96
equal to that counter but the last step
5,069.63
5.37
is I'll also do local storage dot set
5,072.33
6.36
item counter is equal to the new value
5,075
7.29
of counter so what I've done here is to
5,078.69
5.73
say that when I click the button count
5,082.29
3.93
function is going to run we're first
5,084.42
3.84
going to go into local storage get
5,086.22
4.5
value for the key counter whatever the
5,088.26
4.35
value of counter happens to be save it
5,090.72
3.27
inside of this variable called counter
5,092.61
3.03
we'll go ahead and increment that
5,093.99
3.54
variable setting it equal to itself plus
5,095.64
5.07
one update the h1s innerhtml same as
5,097.53
4.56
before just to update what we actually
5,100.71
4.38
see on the page but then go ahead and
5,102.09
6.15
local storage set item counter gets set
5,105.09
8.13
to counter for example so now let's go
5,108.24
9.15
ahead and see what's going to happen if
5,113.22
7.44
I go ahead and open counter dot HTML we
5,117.39
7.71
see 0 we count 1 2 3 4 5 everything so
5,120.66
6.54
far so good now watch what happens if i
5,125.1
5.15
refresh this page i refresh the page and
5,127.2
4.95
alright that seems a little bit strange
5,130.25
4.42
at 0 let me try counting and see what
5,132.15
4.77
happens i press count and alright the
5,134.67
4.8
count changed to 6 so it seems like it
5,136.92
4.56
did remember that i counted up to 5 0 1
5,139.47
4.23
2 3 4 5 but when i refresh the page it
5,141.48
4.38
still showed me 0 but then let me count
5,143.7
3.6
up to the number 6 and I can keep
5,145.86
3.78
counting 7 8 9 10 what happens if i
5,147.3
3.93
refresh the page now I can try it i
5,149.64
4.77
refresh the page I've gone back to 0 but
5,151.23
5.25
I count and okay now I'm at 11 so
5,154.41
3.96
somehow I am still remembering but the
5,156.48
3.6
first time it's still giving me 0 every
5,158.37
4.5
time why might that be well if you look
5,160.08
5.01
back at counter dot HTML you'll notice
5,162.87
3.87
that the reason is just inside the body
5,165.09
3.81
of the page the initial value of the h1
5,166.74
4.5
is just always 0 so if I want to fix
5,168.9
4.26
that then what I need the same is when
5,171.24
4.11
the Dom content is loaded go ahead and
5,173.16
5.97
get document query selector h1 go ahead
5,175.35
5.34
and update the innerhtml
5,179.13
6.68
equal to whatever local storage get item
5,180.69
8.16
counter happens to be so every time I
5,185.81
5.17
open the page even before I click the
5,188.85
3.87
button even before the event listener is
5,190.98
3.6
triggered I'd like to say go ahead and
5,192.72
3.78
replace this heading update its inner
5,194.58
4.95
HTML to be the result of getting the
5,196.5
5.54
counter out of local storage for example
5,199.53
5.76
so now for refresh the page it's all at
5,202.04
5.38
11 I can update update update click
5,205.29
4.32
again some number of times bring it up
5,207.42
4.47
to 18 for example refresh the page and
5,209.61
4.35
it stays at the number 18 and no matter
5,211.89
3.72
what value I get it to it's going to
5,213.96
3.27
store that number inside of local
5,215.61
3.51
storage such that when i refresh the
5,217.23
4.349
page that number is going to stay there
5,219.12
4.229
we can actually see the value inside of
5,221.579
3.721
local storage but again going into
5,223.349
4.98
Chrome's inspector I go into Chrome if I
5,225.3
6.419
go to the application tab and I go to
5,228.329
6.3
local storage here on the Left I can see
5,231.719
4.47
that I have a value for key counter
5,234.629
3.48
whose value in this case happens to be
5,236.189
3.54
28 and you could go into local storage
5,238.109
3.27
you can manipulate this value you could
5,239.729
3.27
delete it if you want but this just goes
5,241.379
3.12
to show you that we have now stored this
5,242.999
4.41
value inside of my browser such that on
5,244.499
4.68
subsequent visits if this page gets
5,247.409
3.81
loaded again we can access that value
5,249.179
4.55
from inside of the application as well
5,251.219
5.07
and so now we've been able to see how
5,253.729
4.45
our pages are able to store data in
5,256.289
3.84
order to just make the user experience a
5,258.179
3.42
little bit better if we want the user to
5,260.129
3.39
be able to have information remembered
5,261.599
3.9
from the last time they visited a
5,263.519
3.33
particular page we can sometimes
5,265.499
5.04
actually be quite helpful all right so
5,266.849
4.92
now we've seen a lot of features of
5,270.539
3