text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
that a language like Python has | 1,006.29 | 3.83 |
conditions ifs and LS and else's | 1,007.82 | 5.34 |
JavaScript too has if and else if and | 1,010.12 | 5.339 |
else that allow us to describe | 1,013.16 | 4.83 |
conditions such that we can only run | 1,015.459 | 4.721 |
certain blocks of code when a particular | 1,017.99 | 4.67 |
boolean expression is true for example | 1,020.18 | 5.07 |
so what would that look like well let's | 1,022.66 | 4.63 |
go ahead and say inside of this hello | 1,025.25 | 5.78 |
function I can ask a question if | 1,027.29 | 7.86 |
document query selector H ones inner | 1,031.03 | 11.62 |
HTML is equal to hello well then go | 1,035.15 | 11.33 |
ahead and set it to goodbye and else | 1,042.65 | 6.54 |
then go ahead and update the inner HTML | 1,046.48 | 6.09 |
this h1 element go ahead and set it to | 1,049.19 | 7.35 |
hello instead so what is this hello | 1,052.57 | 5.32 |
function doing it's now a little bit | 1,056.54 | 2.22 |
more sophisticated | 1,057.89 | 2.97 |
it now has a condition where I say if | 1,058.76 | 4.14 |
the keyword if followed by in | 1,060.86 | 4.199 |
parentheses the condition that I want to | 1,062.9 | 3.6 |
check for the thing I want to see is | 1,065.059 | 3.511 |
this true or not and what I'm checking | 1,066.5 | 5.309 |
for is is let me run document out query | 1,068.57 | 5.58 |
selector h1 which again looks through | 1,071.809 | 5.131 |
the page finds me the h1 tag and get to | 1,074.15 | 4.89 |
that element for me if I look at that | 1,076.94 | 5.52 |
inner HTML if it is equal to hello then | 1,079.04 | 5.31 |
I want to do something and this triple | 1,082.46 | 2.52 |
equals sign | 1,084.35 | 2.52 |
is JavaScript's way of checking for | 1,084.98 | 3.6 |
strict equality checking to make sure | 1,086.87 | 4.23 |
the two values are equal and also that | 1,088.58 | 4.29 |
their types are the same thing that if | 1,091.1 | 3.72 |
this is a string this must also be a | 1,092.87 | 3.78 |
string it turns out in JavaScript is | 1,094.82 | 3.45 |
also a weaker way to check for equality | 1,096.65 | 4.62 |
that just uses two equal signs and that | 1,098.27 | 5.25 |
is going to check the values are the | 1,101.27 | 4.17 |
same but it's going to allow for a bit | 1,103.52 | 4.41 |
of differences in type the two things | 1,105.44 | 4.11 |
might have different types but so long | 1,107.93 | 3.45 |
as they're basically the same value the | 1,109.55 | 3.36 |
double equal sign might generally come | 1,111.38 | 4.23 |
to be true usually if you can you'll | 1,112.91 | 4.53 |
want to use this triple equal sign the | 1,115.61 | 3.75 |
strict equality to make sure that not | 1,117.44 | 3.21 |
only are the types the same but the | 1,119.36 | 3.12 |
values are the same too and the triple | 1,120.65 | 3.06 |
equal sign will check both of those | 1,122.48 | 4.38 |
things so if I go ahead and find the h1 | 1,123.71 | 5.4 |
element and its inner HTML is the word | 1,126.86 | 5.25 |
hello well then go ahead and find the h1 | 1,129.11 | 4.79 |
element and update its inner HTML | 1,132.11 | 4.95 |
setting it equal to goodbye for example | 1,133.9 | 6.64 |
and else go ahead and find that same h1 | 1,137.06 | 6.06 |
element updated inner HTML set it equal | 1,140.54 | 5.19 |
to hello and again just as in functions | 1,143.12 | 4.14 |
where we use these curly braces to | 1,145.73 | 3.69 |
enclose the body of the function all of | 1,147.26 | 3.78 |
the lines of code that are inside of the | 1,149.42 | 3.6 |
function JavaScript does the same thing | 1,151.04 | 3.96 |
to that inside of a condition when we | 1,153.02 | 3.93 |
want to express that this is inside the | 1,155 | 4.17 |
body of an if condition I can use curly | 1,156.95 | 4.23 |
braces to say this line of code in that | 1,159.17 | 3.78 |
line of code that's inside of the if | 1,161.18 | 3.84 |
expression or that's inside of the else | 1,162.95 | 5.04 |
expression for example so let's go ahead | 1,165.02 | 4.47 |
and try this now I can go ahead and open | 1,167.99 | 3.29 |
hello dot HTML | 1,169.49 | 4.26 |
refresh it it currently says hello with | 1,171.28 | 5.25 |
a button that says click here and now | 1,173.75 | 5.79 |
when I click here hello changes to | 1,176.53 | 5.2 |
goodbye and when I click here again | 1,179.54 | 4.5 |
goodbye changes back to hello and every | 1,181.73 | 3.99 |
time I click the button it's going to | 1,184.04 | 3.06 |
alternate between hello and goodbye | 1,185.72 | 3.24 |
because we either get caught in the if | 1,187.1 | 4.35 |
expression or we get caught in the else | 1,188.96 | 5.19 |
expression now there are a couple of | 1,191.45 | 3.93 |
places where you might look at this and | 1,194.15 | 2.73 |
notice that maybe this isn't as | 1,195.38 | 3.45 |
efficient as this code could potentially | 1,196.88 | 4.08 |
be and recall that every time we run | 1,198.83 | 4.77 |
document query selector to say go ahead | 1,200.96 | 4.2 |
and try and find a particular HTML | 1,203.6 | 4.17 |
element for me it's going to look | 1,205.16 | 4.53 |
through that page trying to find the h1 | 1,207.77 | 3.63 |
element and it turns out that right now | 1,209.69 | 4.17 |
we have three separate calls to query | 1,211.4 | 3.99 |
selector even though only two of them | 1,213.86 | 3 |
will ever run on any given instance of | 1,215.39 | 2.66 |
the function but we | 1,216.86 | 3.23 |
document a query selector then we call | 1,218.05 | 4.56 |
it again inside of the if expression we | 1,220.09 | 4.53 |
can probably improve the design of this | 1,222.61 | 4.44 |
page by factoring that out by just | 1,224.62 | 4.65 |
looking for the h1 element once and then | 1,227.05 | 4.41 |
manipulating it and checking it using | 1,229.27 | 4.5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.