text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
page I probably don't just want to
6,173.689
3.3
display the exchange rate between US
6,175.399
3.691
dollars and euros I probably want to let
6,176.989
4.621
the user pick what currencies they would
6,179.09
4.649
like to exchange between and so here's
6,181.61
5.94
how I might go about doing that inside
6,183.739
5.82
of the body of the page now rather than
6,187.55
3.899
just have an empty body let's go ahead
6,189.559
4.02
and add a form that form is going to
6,191.449
4.411
have an input whose ID is currency just
6,193.579
3.63
so I have a way of referencing it later
6,195.86
3.629
the place holder will just be currency
6,197.209
5.64
and the type of it is text and then I'll
6,199.489
5.7
have an input whose type is submit and
6,202.849
4.681
we'll give it a value of convert that'll
6,205.189
3.69
be what the button says it says convert
6,207.53
3.27
and then I can convert to a particular
6,208.879
4.68
currency and then I need some place to
6,210.8
5.129
put my results so I'll go ahead and add
6,213.559
5.82
a div whose ID is result and this is
6,215.929
4.98
where after I've done all the currency
6,219.379
3.211
conversion this is where I'm going to
6,220.909
3.48
put the results of doing that currency
6,222.59
5.67
conversion so now rather than fetch
6,224.389
5.46
right away here's what I need to do I
6,228.26
4.109
need to do something only when the form
6,229.849
3.241
is submitted
6,232.369
3.661
so I can get the form by saying document
6,233.09
6.989
query selector form dot on submit equals
6,236.03
6.359
this function and I'm gonna go ahead and
6,240.079
4.62
just in advance return false at the end
6,242.389
4.23
of the function so we don't actually try
6,244.699
3.54
and submit the form to another page I
6,246.619
3.33
just want to run everything locally on
6,248.239
5.101
this same page but now inside of this
6,249.949
6.42
form once you submit it that is when I
6,253.34
5.159
want to run this code that is going to
6,256.369
4.56
fetch new data so I'm going to fetch
6,258.499
5.16
data from the exchange rates API convert
6,260.929
5.04
that data to Jason same as before then
6,263.659
4.621
go ahead and get access to that data but
6,265.969
4.351
now what I want to do is I want to
6,268.28
4.919
figure out what the user actually typed
6,270.32
4.98
in to the input field and that is going
6,273.199
3.3
to be the currency that I care about
6,275.3
2.909
getting access to so I'll create a
6,276.499
3.93
variable called currency which will be
6,278.209
5.46
equal to document query selector and I
6,280.429
4.77
write the input field if I scroll down
6,283.669
4.62
it has an ID of currency so if I want to
6,285.199
4.811
get that input field I'm
6,288.289
4.541
to say get the element whose ID is
6,290.01
7.08
currency and get its value so this now
6,292.83
7.35
is the currency that the user wanted me
6,297.09
7.05
to get access to and I can then say data
6,300.18
9.15
rates currency instead of data rates dot
6,304.14
7.11
you are and importantly I can't do data
6,309.33
4.29
rates dot currency that would literally
6,311.25
4.11
try to access a property of rates that
6,313.62
4.11
is called currency if I use square
6,315.36
4.5
brackets instead that allows me to use a
6,317.73
3.96
variable something like the currency
6,319.86
3.54
variable which are defined up here on
6,321.69
4.29
line 13 as the currency that the user
6,323.4
4.59
typed in I would like to access that
6,325.98
4.7
particular currency inside of the rates
6,327.99
6.03
and so now I can ask a question there
6,330.68
5.11
are two possibilities here either the
6,334.02
4.11
currency the user typed in it is a valid
6,335.79
5.28
currency or it's not and it turns out
6,338.13
5.13
that if you try and access a property of
6,341.07
4.32
an object that doesn't exist what you
6,343.26
3.42
get back is a particular JavaScript
6,345.39
3.66
variable called undefined meaning there
6,346.68
5.04
is no value there so for example if I
6,349.05
5.61
have something like let person equal
6,351.72
5.82
first name is Harry and last name is
6,354.66
5.61
Potter like we did before I can access
6,357.54
5.04
something like person dot first and get
6,360.27
4.71
Harry I can access person dot last and
6,362.58
4.47
get Potter but if I access person dot
6,364.98
4.08
middle that is going to be a special
6,367.05
3.99
variable in JavaScript or a special
6,369.06
3.99
value in JavaScript called undefined
6,371.04
5.31
meaning there is no value there it's
6,373.05
4.77
slightly different from null which also
6,376.35
3.12
has a similar meaning they're used in
6,377.82
3.78
slightly different contexts so here what
6,379.47
5.06
I can say is if the rate is not
6,381.6
7.05
undefined well then let's go ahead and
6,384.53
10.96
update not the body but the result to
6,388.65
10.05
say one u.s. dollar is equal to this
6,395.49
6.96
rate not necessarily euros but whatever
6,398.7
7.85
the currency happens to be and otherwise
6,402.45
6.51
let's go ahead and document query
6,406.55
6.81
selector result dot inner HTML equals
6,408.96
7.44
invalid currency just to let the user
6,413.36
4.6
know that the currency they tried to
6,416.4
3.87
provide is not actually a valid currency
6,417.96
4.08
and so we're going to need to try a
6,420.27
3.28