Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,050 --> 00:00:03,000
hey guys this is Ross and today we are
2
00:00:03,000 --> 00:00:06,569
doing the JavaScript tutorial cause the
3
00:00:06,569 --> 00:00:08,039
past couple days we did our HTML
4
00:00:08,039 --> 00:00:10,469
tutorial we did our CSS tutorial so
5
00:00:10,469 --> 00:00:12,300
today I'm showing you how to build a
6
00:00:12,300 --> 00:00:15,570
calculator in JavaScript here is what
7
00:00:15,570 --> 00:00:16,859
the calculator is gonna look like I
8
00:00:16,859 --> 00:00:19,980
already wrote it in the HTML and CSS it
9
00:00:19,980 --> 00:00:21,660
will be fully available to you so you
10
00:00:21,660 --> 00:00:23,130
can look at the code you can see how it
11
00:00:23,130 --> 00:00:25,970
works but currently I mean refresh it
12
00:00:25,970 --> 00:00:28,109
currently it doesn't actually do
13
00:00:28,109 --> 00:00:29,910
anything you press buttons nothing
14
00:00:29,910 --> 00:00:32,119
really happens right
15
00:00:32,119 --> 00:00:35,370
nothing nothing happens so again I'm
16
00:00:35,370 --> 00:00:36,719
gonna show you the code for those things
17
00:00:36,719 --> 00:00:38,520
and then I'll show you the JavaScript so
18
00:00:38,520 --> 00:00:40,890
let's jump right in first off we have
19
00:00:40,890 --> 00:00:42,660
our HTML that I wrote for this project
20
00:00:42,660 --> 00:00:45,149
right we have our title as you can see
21
00:00:45,149 --> 00:00:48,210
up here intro to JavaScript I included a
22
00:00:48,210 --> 00:00:50,070
stylesheet just like I showed you in the
23
00:00:50,070 --> 00:00:53,489
last lesson and then in our body I have
24
00:00:53,489 --> 00:00:56,100
a div a divider that contains everything
25
00:00:56,100 --> 00:00:59,850
in here I gave it an ID of app now an ID
26
00:00:59,850 --> 00:01:02,190
is something that we can use to select
27
00:01:02,190 --> 00:01:04,260
this div in particular kind of like we
28
00:01:04,260 --> 00:01:06,000
used classes in the last one we can use
29
00:01:06,000 --> 00:01:08,760
an ID right we see we have class classes
30
00:01:08,760 --> 00:01:10,860
selector we can use in like CSS stuff
31
00:01:10,860 --> 00:01:12,930
like that the difference between a class
32
00:01:12,930 --> 00:01:16,020
and an ID is an ID can only be used for
33
00:01:16,020 --> 00:01:18,659
one element you can use classes for as
34
00:01:18,659 --> 00:01:21,080
many elements as you want you can have
35
00:01:21,080 --> 00:01:23,909
15 or thousand different elements with
36
00:01:23,909 --> 00:01:25,500
the same class name but you must only
37
00:01:25,500 --> 00:01:27,900
have one out element with each ID and
38
00:01:27,900 --> 00:01:30,780
ideas unique to one thing anyway we have
39
00:01:30,780 --> 00:01:33,409
our heading calculator right there I
40
00:01:33,409 --> 00:01:36,000
have a little description and then of
41
00:01:36,000 --> 00:01:37,409
course we have our actual calculator you
42
00:01:37,409 --> 00:01:41,310
see it's just an input a form input and
43
00:01:41,310 --> 00:01:43,409
then a div with a bunch of buttons in
44
00:01:43,409 --> 00:01:45,899
the plus button minus button the times
45
00:01:45,899 --> 00:01:48,570
button the / button the equals symbol
46
00:01:48,570 --> 00:01:51,720
and the Clear button and then of course
47
00:01:51,720 --> 00:01:53,939
down here we have a script tag script
48
00:01:53,939 --> 00:01:56,880
source equals script J s that's how we
49
00:01:56,880 --> 00:01:59,520
pull in the java script writing and then
50
00:01:59,520 --> 00:02:01,409
of course we have the file that we wrote
51
00:02:01,409 --> 00:02:03,240
for the java script called script j s
52
00:02:03,240 --> 00:02:04,320
which there's nothing there right now
53
00:02:04,320 --> 00:02:06,119
also let me just show you the Styles
54
00:02:06,119 --> 00:02:09,389
really quick in our CSS I made the font
55
00:02:09,389 --> 00:02:12,610
family sans-serif so it looks
56
00:02:12,610 --> 00:02:18,490
let's see here what else is there oh let
57
00:02:18,490 --> 00:02:20,260
me let me turn ons in mode really quick
58
00:02:20,260 --> 00:02:25,960
there we go that looks better we just
59
00:02:25,960 --> 00:02:27,370
have some Styles this really isn't
60
00:02:27,370 --> 00:02:29,950
important it's not part of this lesson I
61
00:02:29,950 --> 00:02:31,660
will answer any questions you want about
62
00:02:31,660 --> 00:02:34,360
the styles but let's just get into the
63
00:02:34,360 --> 00:02:36,340
actual JavaScript but everything because
64
00:02:36,340 --> 00:02:37,740
that's what you're here to learn today
65
00:02:37,740 --> 00:02:40,420
so javascript is the way that we're
66
00:02:40,420 --> 00:02:41,770
going to give this functionality we're
67
00:02:41,770 --> 00:02:44,110
gonna make it actually do stuff when we
68
00:02:44,110 --> 00:02:46,510
hit these buttons because currently
69
00:02:46,510 --> 00:02:49,480
nothing's happening javascript is an
70
00:02:49,480 --> 00:02:51,640
actual programming language unlike HTML
71
00:02:51,640 --> 00:02:54,070
unlike CSS javascript can perform logic
72
00:02:54,070 --> 00:02:56,530
it can perform math so I'm just going to
73
00:02:56,530 --> 00:02:58,300
explain a few concepts to you first off
74
00:02:58,300 --> 00:03:00,280
this web browser I'm using Google Chrome
75
00:03:00,280 --> 00:03:04,930
a web browser is really just a way to
76
00:03:04,930 --> 00:03:07,150
view a certain type of document on your
77
00:03:07,150 --> 00:03:08,710
computer and these documents are the
78
00:03:08,710 --> 00:03:10,060
kind that are written in HTML the
79
00:03:10,060 --> 00:03:12,090
written in CSS the written in JavaScript
80
00:03:12,090 --> 00:03:14,410
and when we want to make something
81
00:03:14,410 --> 00:03:16,330
happen in that document we have to call
82
00:03:16,330 --> 00:03:19,060
it from our programming language in this
83
00:03:19,060 --> 00:03:23,430
case JavaScript using the word document
84
00:03:23,430 --> 00:03:25,660
so that's you're just gonna see that in
85
00:03:25,660 --> 00:03:27,010
the code so I just wanted to tell you
86
00:03:27,010 --> 00:03:29,020
that what that is now I'm going to teach
87
00:03:29,020 --> 00:03:30,190
you about something called a variable
88
00:03:30,190 --> 00:03:32,220
alright let me zoom in a little bit
89
00:03:32,220 --> 00:03:37,030
variables a variable stores information
90
00:03:37,030 --> 00:03:38,770
so that it can be used over and over for
91
00:03:38,770 --> 00:03:41,080
example I could have a variable in
92
00:03:41,080 --> 00:03:43,900
JavaScript we just say bear ok and then
93
00:03:43,900 --> 00:03:45,460
you call it something we can call this
94
00:03:45,460 --> 00:03:47,080
one name and it can just hold my name
95
00:03:47,080 --> 00:03:51,910
right and then we can use my name as
96
00:03:51,910 --> 00:03:55,570
much as we want in our application so I
97
00:03:55,570 --> 00:03:57,280
actually made a little example I'm just
98
00:03:57,280 --> 00:03:59,650
gonna paste it in here okay so this is
99
00:03:59,650 --> 00:04:01,120
gonna show well I'll just show you what
100
00:04:01,120 --> 00:04:04,150
it does actually okay so whoa that's ok
101
00:04:04,150 --> 00:04:06,670
let me refresh and here's a little
102
00:04:06,670 --> 00:04:08,380
pop-up box that says hi Ross Libby and
103
00:04:08,380 --> 00:04:10,060
then the next one says Ross Libby did
104
00:04:10,060 --> 00:04:11,800
you miss me and so the next one says ok
105
00:04:11,800 --> 00:04:13,150
Ross let me see you later as you can see
106
00:04:13,150 --> 00:04:16,358
it's a really clean annoying box but the
107
00:04:16,358 --> 00:04:21,940
point is it showed my name three
108
00:04:21,940 --> 00:04:23,680
different times but I only typed it once
109
00:04:23,680 --> 00:04:25,510
because this variable name
110
00:04:25,510 --> 00:04:27,340
store it is so now if I want to make a
111
00:04:27,340 --> 00:04:28,870
change in my program let's say someone
112
00:04:28,870 --> 00:04:30,910
named Billy is using it then I just
113
00:04:30,910 --> 00:04:35,800
write Billy I'll save that and now let
114
00:04:35,800 --> 00:04:37,750
me refresh it it says hi Billy
115
00:04:37,750 --> 00:04:40,180
it says Billy did you miss me and it
116
00:04:40,180 --> 00:04:42,010
says okay Billy see you later as you can
117
00:04:42,010 --> 00:04:44,200
see it said Billy three times but I only
118
00:04:44,200 --> 00:04:45,970
had to write it one time because we
119
00:04:45,970 --> 00:04:47,800
stored it in a variable and then we used
120
00:04:47,800 --> 00:04:49,930
that variable throughout the rest of our
121
00:04:49,930 --> 00:04:51,610
code so variables are very powerful and
122
00:04:51,610 --> 00:04:54,070
I see how those work the next day I'm
123
00:04:54,070 --> 00:04:55,900
gonna teach you about it's called a
124
00:04:55,900 --> 00:05:00,340
function there we go there we go
125
00:05:00,340 --> 00:05:03,250
functions a function is a piece of code
126
00:05:03,250 --> 00:05:05,650
that can be run over and over again it's
127
00:05:05,650 --> 00:05:08,470
basically a set of rules that does
128
00:05:08,470 --> 00:05:10,480
something specific so if you take
129
00:05:10,480 --> 00:05:12,130
something normal like a microwave for
130
00:05:12,130 --> 00:05:15,280
example that has a specific function a
131
00:05:15,280 --> 00:05:17,830
specific function of the microwave is to
132
00:05:17,830 --> 00:05:20,440
make your food warm that's it that's
133
00:05:20,440 --> 00:05:21,970
what it does it makes your food warm it
134
00:05:21,970 --> 00:05:23,910
doesn't make it cold it makes it one a
135
00:05:23,910 --> 00:05:26,050
function in programming is the same it
136
00:05:26,050 --> 00:05:28,540
does something and that's all it does it
137
00:05:28,540 --> 00:05:30,610
does something very specific so an
138
00:05:30,610 --> 00:05:32,740
example of a function I'm going to give
139
00:05:32,740 --> 00:05:36,220
it a name called say hi and this
140
00:05:36,220 --> 00:05:40,780
function is going to say hi okay it's
141
00:05:40,780 --> 00:05:42,790
going to send out unless as that says hi
142
00:05:42,790 --> 00:05:48,250
and now every single time I run this
143
00:05:48,250 --> 00:05:50,170
function by writing its name and putting
144
00:05:50,170 --> 00:05:51,910
some parentheses after that it's going
145
00:05:51,910 --> 00:05:53,830
to say hi it's gonna be really annoying
146
00:05:53,830 --> 00:05:55,750
see there it is right there it says I'm
147
00:05:55,750 --> 00:05:57,280
gonna refresh the page and it says hi
148
00:05:57,280 --> 00:05:59,260
now you might think if that seems kind
149
00:05:59,260 --> 00:06:00,520
of pointless but what if we want to run
150
00:06:00,520 --> 00:06:06,840
that ten times you know say hi say hi 4
151
00:06:06,840 --> 00:06:11,110
6 8 10 now I should say it 10 times but
152
00:06:11,110 --> 00:06:13,090
I only had to write all this code only
153
00:06:13,090 --> 00:06:18,370
once okay hi let's refresh hi hi hi hi
154
00:06:18,370 --> 00:06:20,700
hi
155
00:06:24,340 --> 00:06:28,460
Wow okay so you see it's reusable it's I
156
00:06:28,460 --> 00:06:30,380
wrote that code only once but it said it
157
00:06:30,380 --> 00:06:32,480
every time that I called the function so
158
00:06:32,480 --> 00:06:34,280
as you can see programming is actually
159
00:06:34,280 --> 00:06:35,120
really simple
160
00:06:35,120 --> 00:06:36,710
I showed you some very basic rules and
161
00:06:36,710 --> 00:06:37,670
I'm gonna teach you one more thing
162
00:06:37,670 --> 00:06:38,930
before we get into the actual
163
00:06:38,930 --> 00:06:42,920
functionality of this app all right the
164
00:06:42,920 --> 00:06:44,690
last time going over is called if
165
00:06:44,690 --> 00:06:48,940
statements or conditionals okay
166
00:06:49,870 --> 00:06:52,340
conditionals mean that something only
167
00:06:52,340 --> 00:06:54,890
happens if a condition is met okay it's
168
00:06:54,890 --> 00:06:57,890
really simple it tells your code to do
169
00:06:57,890 --> 00:07:02,390
something only if something is true if
170
00:07:02,390 --> 00:07:05,090
like for example I could say everybody
171
00:07:05,090 --> 00:07:06,980
if your name starts with the letter a
172
00:07:06,980 --> 00:07:09,740
raise your hand and everyone that whose
173
00:07:09,740 --> 00:07:11,060
name starts with an able to raise their
174
00:07:11,060 --> 00:07:13,460
hand and no one else would but if your
175
00:07:13,460 --> 00:07:14,840
name doesn't start with an A you would
176
00:07:14,840 --> 00:07:16,310
not raise your hand you would not follow
177
00:07:16,310 --> 00:07:18,140
that instruction programming is the
178
00:07:18,140 --> 00:07:20,210
exact same it checks if something is
179
00:07:20,210 --> 00:07:23,030
true and if it's true it does that thing
180
00:07:23,030 --> 00:07:25,010
and if it's not true then it skips that
181
00:07:25,010 --> 00:07:27,560
instruction so here's an example okay if
182
00:07:27,560 --> 00:07:32,720
name equals Ross actually excuse me let
183
00:07:32,720 --> 00:07:35,120
me set a variable name equals Ross okay
184
00:07:35,120 --> 00:07:37,419
and now I'm going to check if the name
185
00:07:37,419 --> 00:07:44,290
is Ross then I want you to learn to say
186
00:07:45,010 --> 00:07:50,690
this name is Ross if it's not Ross I
187
00:07:50,690 --> 00:07:53,870
want it to alert and say this is not
188
00:07:53,870 --> 00:07:58,190
Ross all right let's see what happens
189
00:07:58,190 --> 00:08:00,919
oh there's the box it says this name is
190
00:08:00,919 --> 00:08:03,830
Ross now let's see what happens if I
191
00:08:03,830 --> 00:08:08,900
change it to Jack all right this is not
192
00:08:08,900 --> 00:08:11,990
Ross see how that works I didn't have to
193
00:08:11,990 --> 00:08:14,030
change this code at all it just checked
194
00:08:14,030 --> 00:08:17,300
it said is the name Ross is either if it
195
00:08:17,300 --> 00:08:19,880
is then it runs this otherwise else
196
00:08:19,880 --> 00:08:22,700
it runs this that's it if statements are
197
00:08:22,700 --> 00:08:27,290
very simple program is easy and for some
198
00:08:27,290 --> 00:08:28,760
reason they still pay a lot for it so
199
00:08:28,760 --> 00:08:31,669
let's let's get started we're gonna look
200
00:08:31,669 --> 00:08:36,349
at our HTML one more time well probably
201
00:08:36,349 --> 00:08:37,460
more than one more time
202
00:08:37,460 --> 00:08:39,350
for now one more time okay we're going
203
00:08:39,350 --> 00:08:40,880
to write our calculator what we're going
204
00:08:40,880 --> 00:08:43,840
to do we're going to want to modify
205
00:08:43,840 --> 00:08:46,340
we're going to want to know what people
206
00:08:46,340 --> 00:08:48,020
are putting inside of our input for the
207
00:08:48,020 --> 00:08:50,300
number right is that this part right
208
00:08:50,300 --> 00:08:51,440
here we're gonna want to know what
209
00:08:51,440 --> 00:08:53,630
people are typing there we are going to
210
00:08:53,630 --> 00:08:54,830
want to know whether they're clicking
211
00:08:54,830 --> 00:08:57,290
this button or this button or this
212
00:08:57,290 --> 00:08:58,790
button right the add button the subtract
213
00:08:58,790 --> 00:09:00,560
button the x button divide button equals
214
00:09:00,560 --> 00:09:02,120
button clear button you see I've given
215
00:09:02,120 --> 00:09:04,160
them each IDs so that I can reference
216
00:09:04,160 --> 00:09:06,230
each of them individually I can say get
217
00:09:06,230 --> 00:09:08,390
the button with the idea of a door get
218
00:09:08,390 --> 00:09:10,010
the button with the idea of subtracts
219
00:09:10,010 --> 00:09:12,470
right and then I want to tell it what to
220
00:09:12,470 --> 00:09:14,090
happen what should happen if someone
221
00:09:14,090 --> 00:09:18,560
clicks on it so that's pretty much it
222
00:09:18,560 --> 00:09:21,530
let's get started let's get started
223
00:09:21,530 --> 00:09:23,840
writing our script it's gonna be kind of
224
00:09:23,840 --> 00:09:26,090
a long script actually it's about 70
225
00:09:26,090 --> 00:09:28,460
lines but it's cool you guys are smart
226
00:09:28,460 --> 00:09:31,130
the first thing we're going to do make a
227
00:09:31,130 --> 00:09:37,010
function that runs all right we want all
228
00:09:37,010 --> 00:09:38,510
the codes to be contained in a function
229
00:09:38,510 --> 00:09:40,700
and since we're building a calculator
230
00:09:40,700 --> 00:09:42,500
we're gonna call our function calculator
231
00:09:42,500 --> 00:09:44,830
because we're super creative function
232
00:09:44,830 --> 00:09:48,740
calculator there we go that's how we
233
00:09:48,740 --> 00:09:50,030
make it we write the word function we
234
00:09:50,030 --> 00:09:51,470
write the name of it that we make up it
235
00:09:51,470 --> 00:09:55,880
could also be something awesome I wrote
236
00:09:55,880 --> 00:10:00,590
that all something oh if we wanted it to
237
00:10:00,590 --> 00:10:03,280
but I don't I want to be calculator
238
00:10:03,280 --> 00:10:05,750
there we go and then we put parentheses
239
00:10:05,750 --> 00:10:10,220
and then we put curly braces okay next
240
00:10:10,220 --> 00:10:14,240
step we want to get each of these
241
00:10:14,240 --> 00:10:18,230
elements let's see where was the HTML we
242
00:10:18,230 --> 00:10:20,240
want to get this thing and each of these
243
00:10:20,240 --> 00:10:22,280
buttons by their ID so we can use them
244
00:10:22,280 --> 00:10:23,690
in the code so we know what's happening
245
00:10:23,690 --> 00:10:27,010
like I said so wrong button there we go
246
00:10:27,010 --> 00:10:29,300
so let's start by doing that
247
00:10:29,300 --> 00:10:34,150
so get the elements and store them in
248
00:10:34,150 --> 00:10:36,560
variables now you'll notice remember in
249
00:10:36,560 --> 00:10:38,960
HTML we had comments that didn't show up
250
00:10:38,960 --> 00:10:41,300
in the actual thing but they stayed in
251
00:10:41,300 --> 00:10:43,310
the code for us to look at and read for
252
00:10:43,310 --> 00:10:44,660
our own notes that's what these things
253
00:10:44,660 --> 00:10:46,160
are when I put the two slashes in
254
00:10:46,160 --> 00:10:48,650
JavaScript that makes a comment it won't
255
00:10:48,650 --> 00:10:51,070
show up here anywhere
256
00:10:51,070 --> 00:10:54,500
it's just here okay so here we're going
257
00:10:54,500 --> 00:10:56,990
to store the elements and variables so
258
00:10:56,990 --> 00:10:58,880
remember you're right there and then
259
00:10:58,880 --> 00:11:01,370
let's start with the addition button add
260
00:11:01,370 --> 00:11:03,470
we're gonna call it add we can call that
261
00:11:03,470 --> 00:11:06,130
whatever we want to call it add 33
262
00:11:06,130 --> 00:11:09,260
awesomeness if we wanted but now we're
263
00:11:09,260 --> 00:11:11,030
gonna call it add then we're gonna set
264
00:11:11,030 --> 00:11:14,390
it equal to something right that's not
265
00:11:14,390 --> 00:11:14,750
right
266
00:11:14,750 --> 00:11:17,180
we want to store the element from the
267
00:11:17,180 --> 00:11:19,010
HTML remember how I said if we want to
268
00:11:19,010 --> 00:11:22,310
access things from from the webpage we
269
00:11:22,310 --> 00:11:24,410
have to use the word document that's
270
00:11:24,410 --> 00:11:25,630
what we're gonna do we're gonna say
271
00:11:25,630 --> 00:11:28,130
inside of our document which is this
272
00:11:28,130 --> 00:11:32,690
giant thing I want you dot gets elements
273
00:11:32,690 --> 00:11:35,360
right because each of these things is an
274
00:11:35,360 --> 00:11:37,430
element this is the h1 element the P
275
00:11:37,430 --> 00:11:39,650
element the input element right we want
276
00:11:39,650 --> 00:11:42,230
to say get element by ID because we set
277
00:11:42,230 --> 00:11:44,060
an ID on each of them and then we're
278
00:11:44,060 --> 00:11:46,670
just gonna say let's see here what was
279
00:11:46,670 --> 00:11:50,090
this one's ID called it's called add you
280
00:11:50,090 --> 00:11:51,440
know I'm gonna do I'm gonna copy this
281
00:11:51,440 --> 00:11:56,360
list actually so that we can so we don't
282
00:11:56,360 --> 00:11:57,590
have to keep looking back at the file
283
00:11:57,590 --> 00:11:59,660
okay I'm gonna paste it down here this
284
00:11:59,660 --> 00:12:01,670
code will break the website if I try to
285
00:12:01,670 --> 00:12:03,140
run it but we'll just look at it for now
286
00:12:03,140 --> 00:12:05,000
so we know what we're getting right so
287
00:12:05,000 --> 00:12:06,650
for the add button get the element by
288
00:12:06,650 --> 00:12:10,250
the add okay so now this variable is
289
00:12:10,250 --> 00:12:15,350
actually storing this thing it's weird
290
00:12:15,350 --> 00:12:17,810
it's cool though okay so let's do the
291
00:12:17,810 --> 00:12:19,840
same for subtract there some tracks
292
00:12:19,840 --> 00:12:25,270
equals document dot get element by ID
293
00:12:25,510 --> 00:12:31,910
subtracts yeah and then same for
294
00:12:31,910 --> 00:12:39,590
multiply so again if you guys have
295
00:12:39,590 --> 00:12:43,570
questions about anything let me know I
296
00:12:43,570 --> 00:12:46,640
find that you will learn best by doing
297
00:12:46,640 --> 00:12:48,650
which is why I'm using kind of a complex
298
00:12:48,650 --> 00:12:51,230
example to start us out because if you
299
00:12:51,230 --> 00:12:53,390
try to build this and if you fail that
300
00:12:53,390 --> 00:12:55,220
is when you will learn the most if you
301
00:12:55,220 --> 00:12:56,930
have questions about it and I can answer
302
00:12:56,930 --> 00:12:58,790
those questions which I can't answer
303
00:12:58,790 --> 00:13:00,800
those questions if you post them in the
304
00:13:00,800 --> 00:13:02,769
group
305
00:13:02,769 --> 00:13:05,299
that is how you will learn the best the
306
00:13:05,299 --> 00:13:07,249
fastest that is what will prepare you
307
00:13:07,249 --> 00:13:09,919
for real-world scenarios every day at my
308
00:13:09,919 --> 00:13:10,189
job
309
00:13:10,189 --> 00:13:13,189
I run into things that I don't know how
310
00:13:13,189 --> 00:13:17,149
to do and that is what once I figure
311
00:13:17,149 --> 00:13:18,319
those things out that's what pushes me
312
00:13:18,319 --> 00:13:20,089
to be a better developer and just get
313
00:13:20,089 --> 00:13:21,470
better at what I do up here I have a
314
00:13:21,470 --> 00:13:24,559
typo there we go get element by ID that
315
00:13:24,559 --> 00:13:26,959
one is called equals and then the all
316
00:13:26,959 --> 00:13:31,479
clear button fair clear these documents
317
00:13:31,479 --> 00:13:36,919
get elements by IV here all right so I
318
00:13:36,919 --> 00:13:39,319
selected all of those and we probably
319
00:13:39,319 --> 00:13:41,659
want our input to I think I called that
320
00:13:41,659 --> 00:13:45,470
I don't know what I call that doesn't
321
00:13:45,470 --> 00:13:46,519
matter I don't think we need it right
322
00:13:46,519 --> 00:13:51,559
now actually next step you the code
323
00:13:51,559 --> 00:13:53,269
doesn't do anything yet we didn't even
324
00:13:53,269 --> 00:13:57,559
run our function yet so next thing we're
325
00:13:57,559 --> 00:13:58,699
going to do is we're going to make
326
00:13:58,699 --> 00:14:00,169
another function inside of the
327
00:14:00,169 --> 00:14:02,569
calculator function and we are going to
328
00:14:02,569 --> 00:14:05,569
call it do operation because remember in
329
00:14:05,569 --> 00:14:08,389
from basic math right add subtract
330
00:14:08,389 --> 00:14:10,929
multiply divide those are all called
331
00:14:10,929 --> 00:14:15,169
operators okay add does the operation of
332
00:14:15,169 --> 00:14:16,999
adding two things together it does the
333
00:14:16,999 --> 00:14:19,819
plus operation subtract does the -
334
00:14:19,819 --> 00:14:21,709
operation it subtracts one thing from
335
00:14:21,709 --> 00:14:23,809
another right so we're gonna make a
336
00:14:23,809 --> 00:14:27,099
function that does those operations
337
00:14:27,099 --> 00:14:31,369
function do operation remember camel
338
00:14:31,369 --> 00:14:32,689
casing from the last one we do that in
339
00:14:32,689 --> 00:14:35,959
JavaScript - okay and now I'm just going
340
00:14:35,959 --> 00:14:38,569
to make a new variable for number and
341
00:14:38,569 --> 00:14:40,279
I'm going to get the number
342
00:14:40,279 --> 00:14:42,199
oh it's showing me that it's broken
343
00:14:42,199 --> 00:14:43,970
because my you know my code is
344
00:14:43,970 --> 00:14:47,359
incomplete let's let's refresh that okay
345
00:14:47,359 --> 00:14:49,789
whatever the numbers in here mmm there
346
00:14:49,789 --> 00:14:50,209
we go
347
00:14:50,209 --> 00:14:51,949
whatever numbers in here I want to get
348
00:14:51,949 --> 00:14:54,649
that and use the operator on it when
349
00:14:54,649 --> 00:14:58,519
someone clicks a button okay so we're
350
00:14:58,519 --> 00:15:02,419
going to document dot get element by ID
351
00:15:02,419 --> 00:15:06,229
and let's find out what we call that we
352
00:15:06,229 --> 00:15:10,820
called it number Wow that's creative
353
00:15:10,820 --> 00:15:13,910
okay so get element by ID number and we
354
00:15:13,910 --> 00:15:15,350
are going to sue now that's how we're
355
00:15:15,350 --> 00:15:16,550
going to get that variable we're gonna
356
00:15:16,550 --> 00:15:19,550
say that number dot value because it's
357
00:15:19,550 --> 00:15:21,590
an input and when we're using inputs we
358
00:15:21,590 --> 00:15:23,360
can say get the value out of that input
359
00:15:23,360 --> 00:15:26,030
and I can actually prove it to you let's
360
00:15:26,030 --> 00:15:29,660
just do let's not do that right now
361
00:15:29,660 --> 00:15:34,010
actually let's stay on track okay now
362
00:15:34,010 --> 00:15:35,810
the way a calculator usually works is
363
00:15:35,810 --> 00:15:37,520
someone enters a number like five and
364
00:15:37,520 --> 00:15:39,020
then they hit plus and when they hit
365
00:15:39,020 --> 00:15:41,540
plus that five disappears so that you
366
00:15:41,540 --> 00:15:43,460
can enter the next number right so we
367
00:15:43,460 --> 00:15:44,930
want to do that too we want to make that
368
00:15:44,930 --> 00:15:47,090
disappear so we're going to say okay now
369
00:15:47,090 --> 00:15:48,950
that we've stored our number in a
370
00:15:48,950 --> 00:15:51,710
variable let's let's set the value of
371
00:15:51,710 --> 00:15:54,140
this input back to zero so we can enter
372
00:15:54,140 --> 00:15:55,160
the next number so we're gonna say
373
00:15:55,160 --> 00:15:59,960
document okay element by ID number dot
374
00:15:59,960 --> 00:16:01,550
value we're gonna set it equal to
375
00:16:01,550 --> 00:16:05,110
nothing a blank string just empty
376
00:16:05,110 --> 00:16:10,340
quotation marks and then it was
377
00:16:10,340 --> 00:16:12,800
something I forgot we want so this
378
00:16:12,800 --> 00:16:14,720
number is going to be a string that
379
00:16:14,720 --> 00:16:16,790
means JavaScript will see it as text it
380
00:16:16,790 --> 00:16:19,520
will be like saying what is Apple plus
381
00:16:19,520 --> 00:16:22,070
three that won't make any sense we have
382
00:16:22,070 --> 00:16:24,400
to tell JavaScript that this is a number
383
00:16:24,400 --> 00:16:27,740
specifically an integer so an integer is
384
00:16:27,740 --> 00:16:30,380
a number that is not decimal right one
385
00:16:30,380 --> 00:16:32,990
two three four those are all integers
386
00:16:32,990 --> 00:16:35,690
for point five that is not an integer
387
00:16:35,690 --> 00:16:38,510
that is a float that's a double we are
388
00:16:38,510 --> 00:16:39,860
not working with those right now we're
389
00:16:39,860 --> 00:16:42,080
just working with whole numbers okay so
390
00:16:42,080 --> 00:16:47,350
we are going to a set number equal to
391
00:16:47,350 --> 00:16:49,390
itself but we're going to tell
392
00:16:49,390 --> 00:16:51,950
JavaScript parse the number as an
393
00:16:51,950 --> 00:16:53,420
integer so we're gonna use parts in
394
00:16:53,420 --> 00:16:58,130
we're gonna say number so now number
395
00:16:58,130 --> 00:16:59,900
JavaScript knows it's a number so now I
396
00:16:59,900 --> 00:17:01,670
can add it can multiply it can subtract
397
00:17:01,670 --> 00:17:03,380
that you can divide it without getting
398
00:17:03,380 --> 00:17:03,980
confused
399
00:17:03,980 --> 00:17:06,200
it's programming so here's the thing
400
00:17:06,200 --> 00:17:07,700
about programming this is the thing that
401
00:17:07,700 --> 00:17:09,920
people find difficult about it you have
402
00:17:09,920 --> 00:17:11,810
to be extremely specific when you
403
00:17:11,810 --> 00:17:13,550
program if you are not extremely
404
00:17:13,550 --> 00:17:15,740
specific the computer will always follow
405
00:17:15,740 --> 00:17:18,200
your struck instructions exactly and if
406
00:17:18,200 --> 00:17:20,240
you forget to give it an instruction or
407
00:17:20,240 --> 00:17:23,030
you give it too many instructions it
408
00:17:23,030 --> 00:17:24,079
won't actually get
409
00:17:24,079 --> 00:17:27,230
it'll follow all of them like if you
410
00:17:27,230 --> 00:17:30,679
said to somebody go get in the car and
411
00:17:30,679 --> 00:17:32,570
bring the dog with you
412
00:17:32,570 --> 00:17:34,970
right you would expect them to grab the
413
00:17:34,970 --> 00:17:36,830
dog and then go get in the car but a
414
00:17:36,830 --> 00:17:38,779
computer would follow your instructions
415
00:17:38,779 --> 00:17:41,120
in order so first it would go it would
416
00:17:41,120 --> 00:17:42,679
step in the car it would get in there
417
00:17:42,679 --> 00:17:45,019
and then it would try to get the dog but
418
00:17:45,019 --> 00:17:46,640
it wouldn't get out of the car first it
419
00:17:46,640 --> 00:17:48,590
would be stupid and it just wouldn't do
420
00:17:48,590 --> 00:17:48,740
it
421
00:17:48,740 --> 00:17:49,850
that's how computers work they're
422
00:17:49,850 --> 00:17:51,799
actually really stupid and we have to
423
00:17:51,799 --> 00:17:53,419
tell them exactly what to do in the
424
00:17:53,419 --> 00:17:56,210
exact right order we even have to tell
425
00:17:56,210 --> 00:17:58,880
it know the number one is actually a
426
00:17:58,880 --> 00:18:00,889
number not a word that looks like a
427
00:18:00,889 --> 00:18:02,360
number like we actually have to tell it
428
00:18:02,360 --> 00:18:03,889
that stuff so just keep that in mind
429
00:18:03,889 --> 00:18:07,970
okay moving on next step we're going to
430
00:18:07,970 --> 00:18:10,039
use some if statements we're going to
431
00:18:10,039 --> 00:18:12,440
say if the operation if they haven't
432
00:18:12,440 --> 00:18:16,610
clicked anything yet then all we want to
433
00:18:16,610 --> 00:18:18,889
do oh wait I forgot something up here
434
00:18:18,889 --> 00:18:20,570
where we made our variables we need
435
00:18:20,570 --> 00:18:22,100
something that's gonna store the result
436
00:18:22,100 --> 00:18:24,529
right if we add two numbers together
437
00:18:24,529 --> 00:18:27,889
I need something waiting to hold that
438
00:18:27,889 --> 00:18:30,260
result right otherwise we won't be able
439
00:18:30,260 --> 00:18:32,809
to show it so we're gonna save result is
440
00:18:32,809 --> 00:18:35,240
going to be equal to zero right that's a
441
00:18:35,240 --> 00:18:36,950
good way to start out and then we also
442
00:18:36,950 --> 00:18:38,659
want something to know what button you
443
00:18:38,659 --> 00:18:41,269
clicked right we're gonna say did they
444
00:18:41,269 --> 00:18:42,500
click the plus do they click the minus
445
00:18:42,500 --> 00:18:44,360
did they click the times who knows right
446
00:18:44,360 --> 00:18:47,889
so we're gonna say operation is equal to
447
00:18:47,889 --> 00:18:51,350
empty we don't know yet right so down
448
00:18:51,350 --> 00:18:54,169
here we're gonna make an if statement
449
00:18:54,169 --> 00:18:58,070
check if and the operator has been
450
00:18:58,070 --> 00:19:01,250
placed yeah
451
00:19:01,250 --> 00:19:05,179
selected right so if an operator like
452
00:19:05,179 --> 00:19:07,460
plus or minus is selected then this will
453
00:19:07,460 --> 00:19:09,980
actually look like that if - is selector
454
00:19:09,980 --> 00:19:11,779
a bat-like plus if plus is selected
455
00:19:11,779 --> 00:19:13,370
right or actually I think it'll look
456
00:19:13,370 --> 00:19:18,860
more like plus or minus or divide
457
00:19:18,860 --> 00:19:20,840
something like that right but if there's
458
00:19:20,840 --> 00:19:22,039
nothing selected it's just gonna look
459
00:19:22,039 --> 00:19:26,240
empty so let's check if anything's been
460
00:19:26,240 --> 00:19:27,110
selected cake
461
00:19:27,110 --> 00:19:32,630
if operation is equal to nothing then
462
00:19:32,630 --> 00:19:34,760
we're gonna set the result equal to a
463
00:19:34,760 --> 00:19:35,750
number
464
00:19:35,750 --> 00:19:38,490
okay cuz remember we got the number so
465
00:19:38,490 --> 00:19:41,429
if someone clicks here and enters the
466
00:19:41,429 --> 00:19:44,130
number six and then they click on an
467
00:19:44,130 --> 00:19:46,490
operation right before they click that
468
00:19:46,490 --> 00:19:49,470
we are result was zero and our operation
469
00:19:49,470 --> 00:19:51,690
was nothing right so if the operation
470
00:19:51,690 --> 00:19:53,850
was nothing then we say well now the
471
00:19:53,850 --> 00:19:56,520
result is six right because that's what
472
00:19:56,520 --> 00:19:58,320
they answered so now when they click
473
00:19:58,320 --> 00:19:59,789
something else like they enter three and
474
00:19:59,789 --> 00:20:05,909
hit plus I mean or equals then it will
475
00:20:05,909 --> 00:20:07,080
go back through and I'll say well they
476
00:20:07,080 --> 00:20:08,520
had already clicked the plus sign and
477
00:20:08,520 --> 00:20:11,280
they just entered the number three which
478
00:20:11,280 --> 00:20:12,960
would come from here so then it would
479
00:20:12,960 --> 00:20:14,309
add the six into three together you'll
480
00:20:14,309 --> 00:20:16,110
see how it works anyway so if the
481
00:20:16,110 --> 00:20:19,080
operator is nothing then it's gonna set
482
00:20:19,080 --> 00:20:22,520
the results the number check if the plus
483
00:20:22,520 --> 00:20:26,100
operator has been selected
484
00:20:26,100 --> 00:20:33,840
if operation is plus okay
485
00:20:33,840 --> 00:20:35,460
yeah I've been other than bit sick sorry
486
00:20:35,460 --> 00:20:38,010
about that then we're going to set the
487
00:20:38,010 --> 00:20:41,940
result to the results plus number pretty
488
00:20:41,940 --> 00:20:44,130
simple right if it's plus then set our
489
00:20:44,130 --> 00:20:47,120
result to itself plus that cuz let's say
490
00:20:47,120 --> 00:20:48,900
I'm just gonna show you a quick example
491
00:20:48,900 --> 00:20:54,570
right person enters number five person
492
00:20:54,570 --> 00:21:04,770
clicks plus first person enters number
493
00:21:04,770 --> 00:21:09,059
three okay well we want this thing to do
494
00:21:09,059 --> 00:21:16,679
is go okay well result was five and then
495
00:21:16,679 --> 00:21:22,320
they clicks operator plus and then they
496
00:21:22,320 --> 00:21:25,380
click number three so five plus three
497
00:21:25,380 --> 00:21:28,289
equals eight so our result should now
498
00:21:28,289 --> 00:21:29,820
equal eight that's what we're telling
499
00:21:29,820 --> 00:21:32,520
the computer to do okay Bob we had to
500
00:21:32,520 --> 00:21:34,950
say was set the result to itself plus
501
00:21:34,950 --> 00:21:41,730
the number excuse me all right let's
502
00:21:41,730 --> 00:21:43,919
move on do the same thing for minus K
503
00:21:43,919 --> 00:21:47,240
check give minus
504
00:21:47,240 --> 00:21:51,850
Reiter has been selected if operation is
505
00:21:51,850 --> 00:21:56,450
- result equals results
506
00:21:56,450 --> 00:21:58,760
- number should make sense to you by now
507
00:21:58,760 --> 00:22:01,820
let me know if it doesn't if the you
508
00:22:01,820 --> 00:22:03,350
know I'm not even gonna keep writing
509
00:22:03,350 --> 00:22:05,390
these comments cuz I'm signaling no I
510
00:22:05,390 --> 00:22:07,730
will I will I will for you guys so you
511
00:22:07,730 --> 00:22:09,050
can look up back at them and know
512
00:22:09,050 --> 00:22:13,179
exactly what's going on check if the
513
00:22:13,179 --> 00:22:15,679
multiply operator has been selected
514
00:22:15,679 --> 00:22:17,059
right so you take this time of this
515
00:22:17,059 --> 00:22:21,860
operation equals multiply the results
516
00:22:21,860 --> 00:22:30,080
equal the results time number and check
517
00:22:30,080 --> 00:22:32,690
if the divide operator has been selected
518
00:22:32,690 --> 00:22:38,240
if operation divide result equals
519
00:22:38,240 --> 00:22:42,380
results divided by number and we
520
00:22:42,380 --> 00:22:44,830
actually have to UM put this in
521
00:22:44,830 --> 00:22:47,210
parentheses because they got a little
522
00:22:47,210 --> 00:22:49,220
confused for some reason when I ran it
523
00:22:49,220 --> 00:22:53,570
true story I think I don't know we'll
524
00:22:53,570 --> 00:22:56,450
get into that later okay so now we're
525
00:22:56,450 --> 00:22:57,740
handling all these things if someone
526
00:22:57,740 --> 00:22:59,540
clicks nothing or if they click plus
527
00:22:59,540 --> 00:23:02,059
minus multiply divide those are all
528
00:23:02,059 --> 00:23:03,740
things that do operation handles that
529
00:23:03,740 --> 00:23:06,950
function anytime we are handling a
530
00:23:06,950 --> 00:23:09,380
button click we if a button is clicked
531
00:23:09,380 --> 00:23:11,059
we say okay do the operation and we
532
00:23:11,059 --> 00:23:12,860
never have to write any of these lines
533
00:23:12,860 --> 00:23:16,970
of code again okay so let me just give
534
00:23:16,970 --> 00:23:19,730
that a comment and do something if an
535
00:23:19,730 --> 00:23:25,820
operation like an operator clicks all
536
00:23:25,820 --> 00:23:30,470
right let's move on to our clicks now we
537
00:23:30,470 --> 00:23:32,330
have to make sure that anytime
538
00:23:32,330 --> 00:23:34,910
what did I click there okay anytime one
539
00:23:34,910 --> 00:23:36,860
of these buttons is clicked we want to
540
00:23:36,860 --> 00:23:38,240
make sure they know what to do cuz
541
00:23:38,240 --> 00:23:41,300
currently nothing happens alright so
542
00:23:41,300 --> 00:23:44,240
remember how we saved all the buttons in
543
00:23:44,240 --> 00:23:46,130
variables up here well now it's time to
544
00:23:46,130 --> 00:23:47,809
cash in on that okay we're going to tell
545
00:23:47,809 --> 00:23:49,580
add when you're click to do this
546
00:23:49,580 --> 00:23:50,809
subtract when you're click through that
547
00:23:50,809 --> 00:23:55,340
okay let's just start handle the ad
548
00:23:55,340 --> 00:24:00,070
click okay so we say add dot
549
00:24:00,070 --> 00:24:02,200
which dot is a way of accessing things
550
00:24:02,200 --> 00:24:03,729
that can happen to a function or a
551
00:24:03,729 --> 00:24:06,600
variable anyway we're gonna say Dada
552
00:24:06,600 --> 00:24:10,749
Dada add dot on click all one word
553
00:24:10,749 --> 00:24:17,049
equals of function and when it's clicked
554
00:24:17,049 --> 00:24:19,720
we want to do our operation remember the
555
00:24:19,720 --> 00:24:21,399
add operation is clicked so we're gonna
556
00:24:21,399 --> 00:24:23,350
call this say hey do operation and it's
557
00:24:23,350 --> 00:24:24,549
gonna go through and it's going to say
558
00:24:24,549 --> 00:24:26,080
okay did they click this one
559
00:24:26,080 --> 00:24:27,729
or did they click the plus did they
560
00:24:27,729 --> 00:24:29,379
click the minus and it's gonna figure it
561
00:24:29,379 --> 00:24:30,749
out so all we have to write is to
562
00:24:30,749 --> 00:24:34,149
operation and that's it and then we just
563
00:24:34,149 --> 00:24:36,159
have to say okay which operation is
564
00:24:36,159 --> 00:24:37,779
there we have the operation variable up
565
00:24:37,779 --> 00:24:39,190
here we want to say well they click the
566
00:24:39,190 --> 00:24:42,070
Add button they clicked this button so
567
00:24:42,070 --> 00:24:44,109
we gotta set it to a plus so we say
568
00:24:44,109 --> 00:24:49,269
operation equals plus and then we're
569
00:24:49,269 --> 00:24:55,899
going to handle B subtract plate alright
570
00:24:55,899 --> 00:24:58,629
and that's pretty much the same subtract
571
00:24:58,629 --> 00:25:05,070
click equals function to operation
572
00:25:05,489 --> 00:25:11,590
operation equals - all right let's do
573
00:25:11,590 --> 00:25:15,269
the same thing for the multiply click
574
00:25:16,259 --> 00:25:21,729
multiply down click equals function to
575
00:25:21,729 --> 00:25:28,769
operation operation equals multiply
576
00:25:28,769 --> 00:25:32,950
we wrote do operation three times that
577
00:25:32,950 --> 00:25:35,259
means we didn't have to write let's see
578
00:25:35,259 --> 00:25:35,710
here
579
00:25:35,710 --> 00:25:38,349
all these lines of code more than once
580
00:25:38,349 --> 00:25:38,919
okay
581
00:25:38,919 --> 00:25:41,440
we wrote all those lines and we have to
582
00:25:41,440 --> 00:25:43,539
run them every single button that gets
583
00:25:43,539 --> 00:25:44,830
clicked but since we put it in a
584
00:25:44,830 --> 00:25:47,529
function it takes one line instead of
585
00:25:47,529 --> 00:25:54,220
like 20 dang I do not something divided
586
00:25:54,220 --> 00:25:57,519
click let's do a divided click handle
587
00:25:57,519 --> 00:26:02,080
the divide click divided down click
588
00:26:02,080 --> 00:26:07,769
equals function do operation operation
589
00:26:07,769 --> 00:26:09,070
before
590
00:26:09,070 --> 00:26:13,570
divide and the last thing is of course
591
00:26:13,570 --> 00:26:15,940
the clear clique right because we want
592
00:26:15,940 --> 00:26:17,440
to be able to clear the calculator so
593
00:26:17,440 --> 00:26:20,260
I'll handle the clear clique divide or
594
00:26:20,260 --> 00:26:25,350
not clear dot on click equals function
595
00:26:25,350 --> 00:26:28,090
to offer no we don't need to do the
596
00:26:28,090 --> 00:26:30,790
operation we just need to clear what
597
00:26:30,790 --> 00:26:34,960
Evers in the input excuse me
598
00:26:34,960 --> 00:26:39,670
so we're gonna select our input document
599
00:26:39,670 --> 00:26:42,880
dot get element by ID number get set its
600
00:26:42,880 --> 00:26:45,790
value to nothing and then we're gonna
601
00:26:45,790 --> 00:26:48,010
set our result back to zero because
602
00:26:48,010 --> 00:26:49,660
we're clearing the calculator so you can
603
00:26:49,660 --> 00:26:52,170
start over again
604
00:26:52,170 --> 00:26:54,760
I'm believe it or not guys that is all
605
00:26:54,760 --> 00:26:56,800
the code we need to make this work but
606
00:26:56,800 --> 00:26:58,660
you'll notice if we try to run it right
607
00:26:58,660 --> 00:27:00,280
now it's actually not gonna do anything
608
00:27:00,280 --> 00:27:03,520
right oh that didn't clear it all ten
609
00:27:03,520 --> 00:27:06,370
plus five equals nothing it says five
610
00:27:06,370 --> 00:27:08,710
still that's stupid right because we put
611
00:27:08,710 --> 00:27:11,880
all this in a function called calculator
612
00:27:12,510 --> 00:27:15,940
dang I'm having trouble breathing we put
613
00:27:15,940 --> 00:27:17,590
it in a function called calculator and
614
00:27:17,590 --> 00:27:20,050
we forgot to run calculator so let's go
615
00:27:20,050 --> 00:27:21,250
to the bottom of this unless it's right
616
00:27:21,250 --> 00:27:26,560
calculator like that all right now let's
617
00:27:26,560 --> 00:27:27,940
run it and see what happens I'm gonna
618
00:27:27,940 --> 00:27:31,210
refresh the page let's see if it runs
619
00:27:31,210 --> 00:27:34,540
I'm gonna write 10 plus C it cleared and
620
00:27:34,540 --> 00:27:36,960
now I'm gonna write 5 and I'm say and
621
00:27:36,960 --> 00:27:39,760
that that didn't work so let me open my
622
00:27:39,760 --> 00:27:41,490
console really quick there are no errors
623
00:27:41,490 --> 00:27:45,580
let's see if I missed something just go
624
00:27:45,580 --> 00:27:49,270
back to my code really quick oh we
625
00:27:49,270 --> 00:27:50,770
didn't handle what happens if you click
626
00:27:50,770 --> 00:27:53,140
the equals so let's put that right here
627
00:27:53,140 --> 00:27:55,990
before the clear okay handle that equals
628
00:27:55,990 --> 00:28:00,460
click equals dot on click equals
629
00:28:00,460 --> 00:28:08,050
function do operation mmm yep gonna do
630
00:28:08,050 --> 00:28:11,530
our operation document up and then and
631
00:28:11,530 --> 00:28:12,970
this one we're a little bit different
632
00:28:12,970 --> 00:28:16,570
for getting we're setting the we're
633
00:28:16,570 --> 00:28:18,910
gonna set this input to the value of you
634
00:28:18,910 --> 00:28:23,250
know the easy numbers that'd be just
635
00:28:23,850 --> 00:28:26,110
that we just added or subtracted or
636
00:28:26,110 --> 00:28:27,820
operated on right so we're gonna get the
637
00:28:27,820 --> 00:28:29,169
element by ID number so we're gonna
638
00:28:29,169 --> 00:28:30,580
select the input we're gonna set this
639
00:28:30,580 --> 00:28:33,340
value to the results because the result
640
00:28:33,340 --> 00:28:36,279
is what's been storing the operation
641
00:28:36,279 --> 00:28:39,759
right so now let's refresh and see what
642
00:28:39,759 --> 00:28:42,059
happens
643
00:28:42,470 --> 00:28:43,710
[Music]
644
00:28:43,710 --> 00:28:49,210
okay and let's do 10 plus 5 equals and
645
00:28:49,210 --> 00:28:51,639
there we have 15 ok let's click all
646
00:28:51,639 --> 00:28:52,840
clear let's try something else
647
00:28:52,840 --> 00:28:58,899
20 times 3 equals 60 50 divided by 2
648
00:28:58,899 --> 00:29:02,440
equals 25 it's been about 30 minutes
649
00:29:02,440 --> 00:29:04,749
just over and you guys we wrote a fully
650
00:29:04,749 --> 00:29:06,340
functional JavaScript program
651
00:29:06,340 --> 00:29:08,499
congratulations you guys saw how to do
652
00:29:08,499 --> 00:29:10,539
functions and let's see your functions
653
00:29:10,539 --> 00:29:13,679
and variables you saw how to use
654
00:29:13,679 --> 00:29:17,649
conditionals if statements and how to
655
00:29:17,649 --> 00:29:19,720
set on click properties how to access
656
00:29:19,720 --> 00:29:23,559
the document it has been amazing this is
657
00:29:23,559 --> 00:29:25,480
the sort of programming that you can
658
00:29:25,480 --> 00:29:29,549
literally go out and get a job paying
659
00:29:29,549 --> 00:29:31,990
$120,000 a year and you'll be writing
660
00:29:31,990 --> 00:29:34,179
this sort of code I'm not even kidding I
661
00:29:34,179 --> 00:29:36,159
know people that I've done it I've done
662
00:29:36,159 --> 00:29:38,230
it was like it's not difficult once you
663
00:29:38,230 --> 00:29:39,820
get good at this sort of stuff that we
664
00:29:39,820 --> 00:29:42,549
wrote today and just a few other things
665
00:29:42,549 --> 00:29:44,499
but like this is the core stuff this is
666
00:29:44,499 --> 00:29:46,720
the stuff that I had to learn that got
667
00:29:46,720 --> 00:29:49,690
me my first job for 80 thousand dollars
668
00:29:49,690 --> 00:29:51,639
a year this is the first this is the
669
00:29:51,639 --> 00:29:55,200
stuff that I knew when I started making
670
00:29:55,200 --> 00:29:57,909
$45 an hour which is 90,000 a year right
671
00:29:57,909 --> 00:29:59,889
this is the sort of stuff that got me my
672
00:29:59,889 --> 00:30:02,259
first six-figure job so these are the
673
00:30:02,259 --> 00:30:04,179
sort of things you need to know go
674
00:30:04,179 --> 00:30:05,860
through this learning ask me every
675
00:30:05,860 --> 00:30:09,220
question that you want anything you need
676
00:30:09,220 --> 00:30:10,499
to know to understand it because
677
00:30:10,499 --> 00:30:14,529
seriously this is this is just what she
678
00:30:14,529 --> 00:30:16,179
needs to know if you're going to make a
679
00:30:16,179 --> 00:30:19,919
lot of money in the web space so yeah
680
00:30:19,919 --> 00:30:22,029
thanks for watching like comment
681
00:30:22,029 --> 00:30:24,429
subscribe seriously ask any questions
682
00:30:24,429 --> 00:30:27,450
I'm here to teach you
49262
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.