text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
with arrow functions if you ever have a | 5,932.37 | 3.42 |
very simple function that all it's doing | 5,934.14 | 3.57 |
is taking something and returning | 5,935.79 | 4.17 |
something else I can simplify this | 5,937.71 | 4.86 |
function even further and just say I can | 5,939.96 | 4.05 |
omit the curly braces I can omit the | 5,942.57 | 2.01 |
return | 5,944.01 | 3.36 |
I can just say response arrow response | 5,944.58 | 4.86 |
Jason and this is a shorthand way of | 5,947.37 | 4.38 |
saying a function that takes as input | 5,949.44 | 4.44 |
the response and returns as output | 5,951.75 | 5.7 |
response to Jason so here I'm saying go | 5,953.88 | 5.1 |
ahead and fetch me in the latest | 5,957.45 | 3.71 |
exchange rates from this particular API | 5,958.98 | 4.83 |
then convert the response to Jason data | 5,961.16 | 6.88 |
and then once you have the data here's | 5,963.81 | 6.9 |
what I want you to do with that data and | 5,968.04 | 4.65 |
for now let's just go ahead and console | 5,970.71 | 4.38 |
dot log that data just to print it out | 5,972.69 | 4.08 |
to the terminal so we're not doing | 5,975.09 | 3.12 |
anything else to us yet all I'm doing is | 5,976.77 | 3.93 |
saying get me the exchange rates convert | 5,978.21 | 4.32 |
the exchange rates data into Jason and | 5,980.7 | 4.41 |
then let's go ahead and print out that | 5,982.53 | 6.45 |
data so I'll open up currency at HTML | 5,985.11 | 6.48 |
it's a blank page but if I look in the | 5,988.98 | 4.8 |
JavaScript inspector I see what got | 5,991.59 | 4.35 |
logged is a JavaScript object here | 5,993.78 | 4.2 |
indicated by the word object and if I | 5,995.94 | 4.35 |
click the triangle at left I can open up | 5,997.98 | 4.02 |
and see all right inside of this object | 6,000.29 | 5.75 |
is all of this data about exchange rates | 6,002 | 6.09 |
for a whole bunch of different exchange | 6,006.04 | 3.61 |
rates for converting from the US dollar | 6,008.09 | 3.45 |
we're here u.s. dollar one means one | 6,009.65 | 3.81 |
u.s. dollar is one u.s. dollar for | 6,011.54 | 5.01 |
example so now that I've got this data | 6,013.46 | 5.73 |
let's actually try and use this inside | 6,016.55 | 4.14 |
of the program maybe let's say I want to | 6,019.19 | 3.87 |
convert between US Dollars and the | 6,020.69 | 3.54 |
to figure out what the conversion rate | 6,023.06 | 3.63 |
is between dollars and euros well if we | 6,024.23 | 4.68 |
recall what the data looks like the data | 6,026.69 | 5.82 |
is a JavaScript object where we have a | 6,028.91 | 7.08 |
key called rate and inside of rates is | 6,032.51 | 5.94 |
this object and inside of that object I | 6,035.99 | 5.43 |
can access the EU our property to get | 6,038.45 | 4.77 |
the exchange rate of one US dollar is | 6,041.42 | 3.72 |
equal to some number of euros for | 6,043.22 | 4.05 |
example so it's inside of the rates key | 6,045.14 | 4.83 |
and then inside of the EU our key and | 6,047.27 | 5.22 |
that's how I know what to get access to | 6,049.97 | 6.48 |
inside of my data so what I really want | 6,052.49 | 10.11 |
to do is access data dot rates dot EU R | 6,056.45 | 8.04 |
it says get me to all the data that came | 6,062.6 | 4.95 |
back access the rates key and then | 6,064.49 | 5.67 |
access the euro key and we'll go ahead | 6,067.55 | 4.92 |
and save that in a variable called rate | 6,070.16 | 6.69 |
and now I'll just document query | 6,072.47 | 7.08 |
selector body dot innerhtml | 6,076.85 | 5.4 |
equals rate just like take that rate put | 6,079.55 | 5.64 |
it inside of the body so now if i | 6,082.25 | 6.03 |
refresh currency dot HTML what I see is | 6,085.19 | 5.7 |
just this value 0.9 zero eight eight | 6,088.28 | 3.99 |
four three which means that right now | 6,090.89 | 3.51 |
one u.s. dollar happens to be equal to | 6,092.27 | 4.32 |
about zero point nine one euros for | 6,094.4 | 5.16 |
instance so that's useful I could make | 6,096.59 | 4.68 |
this a little more human-friendly by | 6,099.56 | 3.6 |
putting this inside of a template string | 6,101.27 | 5.13 |
I could say one US dollar is equal to | 6,103.16 | 8.37 |
and then rate euros for example and so | 6,106.4 | 8.13 |
now if i refresh the page I see one u.s. | 6,111.53 | 5.64 |
dollar is equal to this many euros and | 6,114.53 | 4.38 |
even this is a little bit annoying I | 6,117.17 | 2.91 |
probably don't care about it too this | 6,118.91 | 3.18 |
many decimal places and some really in | 6,120.08 | 3.63 |
the mood to be very precise about these | 6,122.09 | 3.51 |
exchange rates if I only care about it | 6,123.71 | 4.14 |
to like 3 decimal places for example it | 6,125.6 | 4.17 |
turns out JavaScript has functions I can | 6,127.85 | 4.73 |
use on numbers like rate dot two fixed | 6,129.77 | 5.76 |
passing in three as an argument there to | 6,132.58 | 4.39 |
mean I'd like to take this exchange rate | 6,135.53 | 3.6 |
and just round it to three decimal | 6,136.97 | 4.8 |
places for example so now i refresh the | 6,139.13 | 5.16 |
page and I see one u.s. dollar is equal | 6,141.77 | 4.86 |
to zero point nine zero nine euros and | 6,144.29 | 3.45 |
the interesting thing about what's | 6,146.63 | 3 |
happening here is this is happening as a | 6,147.74 | 4.29 |
result of an asynchronous request I am | 6,149.63 | 4.89 |
asking for the latest exchange rates and | 6,152.03 | 4.619 |
when I get back the exchange rates date | 6,154.52 | 4.229 |
javascript is plugging that information | 6,156.649 | 3.99 |
into the body of the page I now | 6,158.749 | 4.321 |
communicating with an API getting back | 6,160.639 | 5.01 |
that api's data in JSON form and then | 6,163.07 | 5.25 |
using that data to update the contents | 6,165.649 | 6.09 |
of my HTML page of course in practice if | 6,168.32 | 5.369 |
I really want a currency exchange web | 6,171.739 | 3.66 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.