text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
function and other functions that we can
560.38
3.51
write for ourselves functions like hello
562.27
3.63
but we also have the ability to include
563.89
4.83
things like variables inside of our
565.9
5.1
program as well so what might that look
568.72
2.61
like
571
2.31
well I'll go ahead and create a new file
571.33
5.82
it will call counter HTML and counter is
573.31
5.4
going to have some of the similar code
577.15
2.79
to hello so I'll just go ahead and copy
578.71
3.27
it for now but I'll clear out the script
579.94
4.02
section change the title from hello to
581.98
6.51
counter and now inside I'll get rid of
583.96
6.03
the button or actually I'll keep the
588.49
3.69
button but instead of saying click here
589.99
5.19
the button is going to say count I'd
592.18
4.14
like to create a program that just
595.18
3.12
counts for me from zero to one two two
596.32
5.76
three four so on and so forth and now in
598.3
6
order to do that in order to have some
602.08
4.23
way of counting repeatedly zero one two
604.3
4.68
three four five I'm going to need a have
606.31
4.38
some sort of variable inside of my
608.98
3.21
program something that is keeping track
610.69
3.69
of data like the number that I'm
612.19
4.35
currently have counted to so in order to
614.38
3.87
do that in JavaScript I can say
616.54
5.07
something like let counter equal zero
618.25
5.76
this is the way in JavaScript that I
621.61
5.07
define a new variable I first say let
624.01
4.68
counter meaning let there be a new
626.68
4.14
variable called counter and I'm going to
628.69
4.17
initially set the value of counter equal
630.82
5.01
to the number zero and now when I click
632.86
4.65
on the button instead of running the
635.83
3.72
hello function I'm going to go ahead and
637.51
4.95
run the count function which doesn't
639.55
4.95
exist yet but I'll now write it I'll
642.46
5.43
define a function called count and what
644.5
6.06
the count function is going to do is it
647.89
5.28
is going to first increment the value of
650.56
4.26
counter and a number of ways I could do
653.17
3.36
that one is my saying counter equals
654.82
4.98
counter plus one to say go ahead and
656.53
4.53
reset the value of counter to whatever
659.8
3.48
it counter is plus one and there are a
661.06
3.78
couple of shorthand notations for this I
663.28
3.72
could equivalently say counter plus
664.84
4.38
equals one to say add one to the counter
667
5.04
or in the case of adding one javascript
669.22
4.2
much like languages like c if you've
672.04
3.09
seen them before and support notation
673.42
4.02
like this counter plus plus which just
675.13
3.75
means take the value of counter and
677.44
2.88
increment it add 1 to it
678.88
3.78
so I'll add 1 to the value of counter
680.32
4.98
and then I'll just display an alert
682.66
5.46
that has whatever the current value of
685.3
6.06
counter happens to be and so I've
688.12
4.77
incremented the value of counter and
691.36
3.75
then displayed an alert that shows me
692.89
4.199
what's contained inside of counter and
695.11
6.419
so now if I go ahead and not go to hello
697.089
6.661
dot HTML but to counter dot HTML instead
701.529
5.31
I now see that I still see a button that
703.75
4.829
says count and if I click on that button
706.839
4.351
I get an alert that this time says one
708.579
4.38
we've incrementing the value of counter
711.19
3.99
from zero to one the alert now says 1
712.959
4.62
and I can press ok if I press count
715.18
5.61
again the count now goes to 2 I press ok
717.579
5.581
press count again it goes to 3 and every
720.79
3.87
time I click count it is going to
723.16
3.72
increment the value of the variable
724.66
4.619
counter inside of my JavaScript webpage
726.88
4.26
and then it's going to display an alert
729.279
4.261
that is going to contain the value of
731.14
3.21
that variable
733.54
3.03
so using alerts now we're able to
734.35
3.66
manipulate that we can inside a
736.57
2.82
functions manipulate the values of
738.01
3.24
variables and then display alerts that
739.39
3.9
show the contents of those variable ism
741.25
3.779
but ultimately when users are
743.29
3.57
interacting with the page it's going to
745.029
3.661
be fairly annoying if the only way that
746.86
4.289
we have to interact with the user is via
748.69
4.17
displaying these alerts the equivalent
751.149
3.151
of like printing something out except
752.86
2.969
instead of printing it to a terminal
754.3
3.51
we're printing it via an alert that
755.829
3.901
appears on the screen what would be more
757.81
3.57
interesting and more powerful and much
759.73
3.21
more useful in the context of a webpage
761.38
4.5
is if we could programmatically update
762.94
4.889
the website change something about the
765.88
3.57
webpage the user is actually seeing
767.829
4.111
changing the content that happens to be
769.45
4.71
on the page and turns out Java Script is
771.94
3.69
going to enable us to do that as well
774.16
3.419