diff --git "a/x5trGVMKTdY.json" "b/x5trGVMKTdY.json" new file mode 100644--- /dev/null +++ "b/x5trGVMKTdY.json" @@ -0,0 +1,14957 @@ +[ + { + "text": "[Music]", + "start": 0.56, + "duration": 15.46 + }, + { + "text": "you", + "start": 13.96, + "duration": 2.06 + }, + { + "text": "okay welcome back everyone to web", + "start": 17.33, + "duration": 3.63 + }, + { + "text": "programming with Python and JavaScript", + "start": 19.49, + "duration": 3.449 + }, + { + "text": "and today we turn our attention to the", + "start": 20.96, + "duration": 3.84 + }, + { + "text": "second of the main programming languages", + "start": 22.939, + "duration": 3.061 + }, + { + "text": "that would be looking under this class", + "start": 24.8, + "duration": 3.54 + }, + { + "text": "in particular JavaScript and to get an", + "start": 26.0, + "duration": 3.57 + }, + { + "text": "understanding for why it is that", + "start": 28.34, + "duration": 3.269 + }, + { + "text": "JavaScript is actually helpful let's go", + "start": 29.57, + "duration": 3.9 + }, + { + "text": "back and revisit this diagram of what", + "start": 31.609, + "duration": 3.541 + }, + { + "text": "communication over the Internet will", + "start": 33.47, + "duration": 3.45 + }, + { + "text": "generally look like oftentimes we'll", + "start": 35.15, + "duration": 3.24 + }, + { + "text": "have a user otherwise known as the", + "start": 36.92, + "duration": 3.69 + }, + { + "text": "client using their computer on their web", + "start": 38.39, + "duration": 3.87 + }, + { + "text": "browser whether that's Chrome or Safari", + "start": 40.61, + "duration": 3.99 + }, + { + "text": "or some other web browser that sends an", + "start": 42.26, + "duration": 5.549 + }, + { + "text": "HTTP request a web request to some sort", + "start": 44.6, + "duration": 5.459 + }, + { + "text": "of web server that server then processes", + "start": 47.809, + "duration": 4.5 + }, + { + "text": "that request and then returns some sort", + "start": 50.059, + "duration": 3.991 + }, + { + "text": "of response that comes back to the", + "start": 52.309, + "duration": 3.96 + }, + { + "text": "client thus far all of the code that", + "start": 54.05, + "duration": 4.2 + }, + { + "text": "we've written the Python web application", + "start": 56.269, + "duration": 4.02 + }, + { + "text": "code running in a Django web application", + "start": 58.25, + "duration": 4.05 + }, + { + "text": "for example has all been code that runs", + "start": 60.289, + "duration": 4.291 + }, + { + "text": "on some sort of server code that is", + "start": 62.3, + "duration": 4.11 + }, + { + "text": "listening for requests doing some", + "start": 64.58, + "duration": 3.45 + }, + { + "text": "computation in order to process that", + "start": 66.41, + "duration": 3.69 + }, + { + "text": "request and then generating some sort of", + "start": 68.03, + "duration": 4.259 + }, + { + "text": "response usually in the form of an HTML", + "start": 70.1, + "duration": 4.56 + }, + { + "text": "template that we then send back to the", + "start": 72.289, + "duration": 4.5 + }, + { + "text": "client what JavaScript is going to", + "start": 74.66, + "duration": 4.14 + }, + { + "text": "enable us to do is to begin to write", + "start": 76.789, + "duration": 4.591 + }, + { + "text": "client-side code javascript is going to", + "start": 78.8, + "duration": 4.019 + }, + { + "text": "allow us to write code that actually", + "start": 81.38, + "duration": 3.81 + }, + { + "text": "runs and inside of the users web browser", + "start": 82.819, + "duration": 4.591 + }, + { + "text": "on the client and this can be useful for", + "start": 85.19, + "duration": 3.989 + }, + { + "text": "a number of reasons one if there's", + "start": 87.41, + "duration": 3.51 + }, + { + "text": "computation that we want to do but we", + "start": 89.179, + "duration": 3.181 + }, + { + "text": "don't need to go out and reach out to a", + "start": 90.92, + "duration": 3.449 + }, + { + "text": "server in order to do so we can do the", + "start": 92.36, + "duration": 4.349 + }, + { + "text": "computation potentially faster just by", + "start": 94.369, + "duration": 4.051 + }, + { + "text": "running the code exclusively on the", + "start": 96.709, + "duration": 3.66 + }, + { + "text": "client and in addition to that we can", + "start": 98.42, + "duration": 3.869 + }, + { + "text": "begin to make our web pages a whole lot", + "start": 100.369, + "duration": 3.75 + }, + { + "text": "more interactive javascript is going to", + "start": 102.289, + "duration": 3.631 + }, + { + "text": "give us the ability to directly", + "start": 104.119, + "duration": 4.021 + }, + { + "text": "manipulate the Dom where again the Dom", + "start": 105.92, + "duration": 5.009 + }, + { + "text": "is the document object model that tree", + "start": 108.14, + "duration": 5.069 + }, + { + "text": "like hierarchy that represents the web", + "start": 110.929, + "duration": 3.78 + }, + { + "text": "page that the user happens to be looking", + "start": 113.209, + "duration": 3.841 + }, + { + "text": "at so javascript will enable us to write", + "start": 114.709, + "duration": 4.05 + }, + { + "text": "code that directly manipulates the", + "start": 117.05, + "duration": 3.42 + }, + { + "text": "content on the web page and we'll see", + "start": 118.759, + "duration": 3.661 + }, + { + "text": "how that can be quite powerful very soon", + "start": 120.47, + "duration": 4.709 + }, + { + "text": "so how do we then use JavaScript inside", + "start": 122.42, + "duration": 5.19 + }, + { + "text": "of a web page in order to add some code", + "start": 125.179, + "duration": 4.321 + }, + { + "text": "add some programming logic to a web page", + "start": 127.61, + "duration": 4.739 + }, + { + "text": "well so far we've already seen HTML the", + "start": 129.5, + "duration": 4.08 + }, + { + "text": "language we use to describe the", + "start": 132.349, + "duration": 2.28 + }, + { + "text": "structure of a web page", + "start": 133.58, + "duration": 3.84 + }, + { + "text": "where a HTML page just describes the", + "start": 134.629, + "duration": 4.351 + }, + { + "text": "structure of a page and in terms of", + "start": 137.42, + "duration": 3.84 + }, + { + "text": "nested tags we had those head tags at", + "start": 138.98, + "duration": 4.17 + }, + { + "text": "the top of the page the body tags that", + "start": 141.26, + "duration": 3.54 + }, + { + "text": "describe the structure of the page and", + "start": 143.15, + "duration": 2.94 + }, + { + "text": "then additional tags that could be", + "start": 144.8, + "duration": 3.63 + }, + { + "text": "nested within those and in order to add", + "start": 146.09, + "duration": 4.29 + }, + { + "text": "JavaScript to a web page if it's as", + "start": 148.43, + "duration": 2.76 + }, + { + "text": "simple as include", + "start": 150.38, + "duration": 3.06 + }, + { + "text": "some script tags that are often located", + "start": 151.19, + "duration": 5.79 + }, + { + "text": "inside of the HTML page itself when we", + "start": 153.44, + "duration": 5.34 + }, + { + "text": "use these script tags we're telling the", + "start": 156.98, + "duration": 3.99 + }, + { + "text": "browser that anything in between these", + "start": 158.78, + "duration": 4.14 + }, + { + "text": "script tags should be interpreted in", + "start": 160.97, + "duration": 4.41 + }, + { + "text": "this case as JavaScript code that the", + "start": 162.92, + "duration": 5.37 + }, + { + "text": "web browser is then going to execute so", + "start": 165.38, + "duration": 4.83 + }, + { + "text": "our very first program for example might", + "start": 168.29, + "duration": 3.93 + }, + { + "text": "just look like a line of code inside of", + "start": 170.21, + "duration": 3.69 + }, + { + "text": "the script tags something like this", + "start": 172.22, + "duration": 4.35 + }, + { + "text": "where alert for example is the name of a", + "start": 173.9, + "duration": 4.14 + }, + { + "text": "function a function that's going to", + "start": 176.57, + "duration": 3.99 + }, + { + "text": "produce an alert and then just as with", + "start": 178.04, + "duration": 4.05 + }, + { + "text": "functions in Python functions in", + "start": 180.56, + "duration": 3.45 + }, + { + "text": "JavaScript can take arguments so in", + "start": 182.09, + "duration": 3.69 + }, + { + "text": "between these parentheses we have an", + "start": 184.01, + "duration": 3.78 + }, + { + "text": "argument something like a string hello", + "start": 185.78, + "duration": 3.57 + }, + { + "text": "world the text that we would like to", + "start": 187.79, + "duration": 4.26 + }, + { + "text": "display to the user so let's go ahead", + "start": 189.35, + "duration": 4.56 + }, + { + "text": "and give this a try and see how we can", + "start": 192.05, + "duration": 3.57 + }, + { + "text": "actually use this code to write", + "start": 193.91, + "duration": 3.93 + }, + { + "text": "JavaScript that is going to run inside", + "start": 195.62, + "duration": 4.56 + }, + { + "text": "of the user's web browser I'll go ahead", + "start": 197.84, + "duration": 4.44 + }, + { + "text": "and create a new file that will call", + "start": 200.18, + "duration": 6.23 + }, + { + "text": "hello HTML and inside of it I'll include", + "start": 202.28, + "duration": 8.01 + }, + { + "text": "the same basic HTML structure that we've", + "start": 206.41, + "duration": 5.38 + }, + { + "text": "already seen before where I have a head", + "start": 210.29, + "duration": 3.51 + }, + { + "text": "section that has a title and then a body", + "start": 211.79, + "duration": 4.61 + }, + { + "text": "that maybe just says hello for example", + "start": 213.8, + "duration": 5.82 + }, + { + "text": "and so now what I'd like to do is add a", + "start": 216.4, + "duration": 5.14 + }, + { + "text": "little bit of JavaScript to this web", + "start": 219.62, + "duration": 4.14 + }, + { + "text": "page so in the head section of my web", + "start": 221.54, + "duration": 4.8 + }, + { + "text": "page I'm gonna go ahead and add a script", + "start": 223.76, + "duration": 5.07 + }, + { + "text": "tag we're in between these script tags", + "start": 226.34, + "duration": 5.22 + }, + { + "text": "now I can write JavaScript code code", + "start": 228.83, + "duration": 3.6 + }, + { + "text": "that is going to be written in", + "start": 231.56, + "duration": 2.85 + }, + { + "text": "JavaScript that will run inside of the", + "start": 232.43, + "duration": 4.38 + }, + { + "text": "web browser when the user actually opens", + "start": 234.41, + "duration": 4.23 + }, + { + "text": "up this page and for now I'll just say", + "start": 236.81, + "duration": 6.24 + }, + { + "text": "alert and then hello world it turns out", + "start": 238.64, + "duration": 6.21 + }, + { + "text": "in JavaScript you can use either single", + "start": 243.05, + "duration": 3.45 + }, + { + "text": "quotation marks or double quotation", + "start": 244.85, + "duration": 3.21 + }, + { + "text": "marks in order to represent strings and", + "start": 246.5, + "duration": 3.48 + }, + { + "text": "I'll generally use single quotation", + "start": 248.06, + "duration": 4.17 + }, + { + "text": "marks here just by convention so here", + "start": 249.98, + "duration": 3.479 + }, + { + "text": "I'm running a function called alert", + "start": 252.23, + "duration": 2.46 + }, + { + "text": "that's going to display an alert", + "start": 253.459, + "duration": 2.791 + }, + { + "text": "something like hello world to the user", + "start": 254.69, + "duration": 3.96 + }, + { + "text": "and that's going to be inside of the", + "start": 256.25, + "duration": 6.69 + }, + { + "text": "script tags of this HTML page so now if", + "start": 258.65, + "duration": 6.39 + }, + { + "text": "I want to actually open the page up I", + "start": 262.94, + "duration": 4.32 + }, + { + "text": "can open hello dot HTML or you could", + "start": 265.04, + "duration": 3.6 + }, + { + "text": "just visit it inside of your web browser", + "start": 267.26, + "duration": 2.7 + }, + { + "text": "whether it's Chrome or something else", + "start": 268.64, + "duration": 3.39 + }, + { + "text": "and now at the top of the page what", + "start": 269.96, + "duration": 3.63 + }, + { + "text": "you'll notice is that I get a little bit", + "start": 272.03, + "duration": 3.75 + }, + { + "text": "of an alert some interaction where it", + "start": 273.59, + "duration": 4.35 + }, + { + "text": "says this page says hello world and", + "start": 275.78, + "duration": 3.48 + }, + { + "text": "gives me an option to like press a", + "start": 277.94, + "duration": 3.599 + }, + { + "text": "button for example like Hello I'd like", + "start": 279.26, + "duration": 3.75 + }, + { + "text": "the OK button that'll say all right", + "start": 281.539, + "duration": 2.851 + }, + { + "text": "dismiss the alert now", + "start": 283.01, + "duration": 3.09 + }, + { + "text": "and this is our very first example of", + "start": 284.39, + "duration": 2.94 + }, + { + "text": "JavaScript we have a function called", + "start": 286.1, + "duration": 3.45 + }, + { + "text": "alert built into JavaScript for our web", + "start": 287.33, + "duration": 3.96 + }, + { + "text": "browser and our web browser knows that", + "start": 289.55, + "duration": 3.48 + }, + { + "text": "when we call the alert function the", + "start": 291.29, + "duration": 3.6 + }, + { + "text": "browser should display an alert message", + "start": 293.03, + "duration": 3.72 + }, + { + "text": "that looks a little something like that", + "start": 294.89, + "duration": 3.75 + }, + { + "text": "and if i click the ok' button to dismiss", + "start": 296.75, + "duration": 3.9 + }, + { + "text": "the alert then we go ahead and get back", + "start": 298.64, + "duration": 4.41 + }, + { + "text": "the original page that i had from the", + "start": 300.65, + "duration": 5.4 + }, + { + "text": "beginning and so now we can begin to", + "start": 303.05, + "duration": 4.98 + }, + { + "text": "imagine that using this ability to", + "start": 306.05, + "duration": 4.11 + }, + { + "text": "programmatically display alerts that we", + "start": 308.03, + "duration": 4.11 + }, + { + "text": "can add additional features to our", + "start": 310.16, + "duration": 4.17 + }, + { + "text": "applications as well and one big area", + "start": 312.14, + "duration": 3.57 + }, + { + "text": "where javascript can be quite powerful", + "start": 314.33, + "duration": 3.81 + }, + { + "text": "is with isn't driven programming and", + "start": 315.71, + "duration": 3.96 + }, + { + "text": "what event-driven programming is all", + "start": 318.14, + "duration": 3.45 + }, + { + "text": "about is thinking about things that", + "start": 319.67, + "duration": 4.14 + }, + { + "text": "happen on the web in terms of events", + "start": 321.59, + "duration": 4.29 + }, + { + "text": "that happen what are some examples of", + "start": 323.81, + "duration": 4.08 + }, + { + "text": "events events are things like the user", + "start": 325.88, + "duration": 4.38 + }, + { + "text": "clicks on a button or the user selects", + "start": 327.89, + "duration": 4.02 + }, + { + "text": "something from a drop-down list or the", + "start": 330.26, + "duration": 3.6 + }, + { + "text": "user Scrolls through a list or submits a", + "start": 331.91, + "duration": 3.78 + }, + { + "text": "form anything the user does and can", + "start": 333.86, + "duration": 3.54 + }, + { + "text": "generally be thought of as an event and", + "start": 335.69, + "duration": 4.05 + }, + { + "text": "what we can do with javascript is add", + "start": 337.4, + "duration": 4.98 + }, + { + "text": "event listeners or event handlers things", + "start": 339.74, + "duration": 5.1 + }, + { + "text": "that say when an event happens go ahead", + "start": 342.38, + "duration": 4.74 + }, + { + "text": "and run this particular block of code or", + "start": 344.84, + "duration": 4.74 + }, + { + "text": "this function for example and using that", + "start": 347.12, + "duration": 4.26 + }, + { + "text": "we can begin to allow our JavaScript", + "start": 349.58, + "duration": 4.05 + }, + { + "text": "code to respond to how the user is", + "start": 351.38, + "duration": 4.29 + }, + { + "text": "actually interacting with our web page", + "start": 353.63, + "duration": 3.72 + }, + { + "text": "to say when the user clicks on a button", + "start": 355.67, + "duration": 3.56 + }, + { + "text": "I would like to run this particular", + "start": 357.35, + "duration": 5.4 + }, + { + "text": "JavaScript function for example so let's", + "start": 359.23, + "duration": 5.29 + }, + { + "text": "go ahead and give that a try I'll go", + "start": 362.75, + "duration": 3.99 + }, + { + "text": "ahead and now instead of just saying", + "start": 364.52, + "duration": 4.86 + }, + { + "text": "alert hello world let me put this alert", + "start": 366.74, + "duration": 4.74 + }, + { + "text": "inside of a function and to create a", + "start": 369.38, + "duration": 4.17 + }, + { + "text": "function in JavaScript you just use the", + "start": 371.48, + "duration": 4.41 + }, + { + "text": "keyword function followed by the name of", + "start": 373.55, + "duration": 3.54 + }, + { + "text": "the function I'll call the function", + "start": 375.89, + "duration": 3.03 + }, + { + "text": "hello for example and then in", + "start": 377.09, + "duration": 3.84 + }, + { + "text": "parenthesis any inputs that function", + "start": 378.92, + "duration": 3.75 + }, + { + "text": "takes this hello function is not going", + "start": 380.93, + "duration": 3.18 + }, + { + "text": "to take any input so I'll just use an", + "start": 382.67, + "duration": 4.53 + }, + { + "text": "empty set of parentheses and then inside", + "start": 384.11, + "duration": 5.82 + }, + { + "text": "of curly braces I include any of the", + "start": 387.2, + "duration": 5.04 + }, + { + "text": "code that I want to run in this function", + "start": 389.93, + "duration": 5.01 + }, + { + "text": "and so what I've done here now is create", + "start": 392.24, + "duration": 5.1 + }, + { + "text": "a function called hello and then inside", + "start": 394.94, + "duration": 3.87 + }, + { + "text": "of the curly braces have defined the", + "start": 397.34, + "duration": 3.06 + }, + { + "text": "body of the function what code should", + "start": 398.81, + "duration": 3.93 + }, + { + "text": "run when I run the hello function and", + "start": 400.4, + "duration": 4.71 + }, + { + "text": "what the hello function should do is it", + "start": 402.74, + "duration": 3.96 + }, + { + "text": "should display an alert that in this", + "start": 405.11, + "duration": 4.59 + }, + { + "text": "case says a hello world so now what I'd", + "start": 406.7, + "duration": 5.88 + }, + { + "text": "like to do is get this function to run", + "start": 409.7, + "duration": 5.46 + }, + { + "text": "when something happens on the page for", + "start": 412.58, + "duration": 5.37 + }, + { + "text": "example when a user clicks on a button", + "start": 415.16, + "duration": 4.08 + }, + { + "text": "so to do that the first thing I'll need", + "start": 417.95, + "duration": 3.69 + }, + { + "text": "to do is actually create a button so add", + "start": 419.24, + "duration": 4.56 + }, + { + "text": "a button that just says like click here", + "start": 421.64, + "duration": 5.82 + }, + { + "text": "for example so now if i refresh this", + "start": 423.8, + "duration": 7.44 + }, + { + "text": "page i now see that i have hello and I", + "start": 427.46, + "duration": 5.01 + }, + { + "text": "also have this button that says click", + "start": 431.24, + "duration": 3.69 + }, + { + "text": "here but when I click here like nothing", + "start": 432.47, + "duration": 3.69 + }, + { + "text": "happens I'm clicking the click here", + "start": 434.93, + "duration": 2.46 + }, + { + "text": "button but it's not changing anything", + "start": 436.16, + "duration": 3.24 + }, + { + "text": "because I haven't yet said what should", + "start": 437.39, + "duration": 4.56 + }, + { + "text": "happen when the user does click on this", + "start": 439.4, + "duration": 4.71 + }, + { + "text": "button and so one way we could do this", + "start": 441.95, + "duration": 5.1 + }, + { + "text": "is by adding an attribute to this HTML", + "start": 444.11, + "duration": 6.66 + }, + { + "text": "element called unclick what this is", + "start": 447.05, + "duration": 5.97 + }, + { + "text": "going to do is it's going to add an on", + "start": 450.77, + "duration": 3.99 + }, + { + "text": "click handler to this button it's going", + "start": 453.02, + "duration": 3.48 + }, + { + "text": "to say what should happen when the user", + "start": 454.76, + "duration": 3.96 + }, + { + "text": "clicks on this button and I'm going to", + "start": 456.5, + "duration": 4.19 + }, + { + "text": "set the onclick attribute equal to", + "start": 458.72, + "duration": 5.13 + }, + { + "text": "running the function hello and in order", + "start": 460.69, + "duration": 4.84 + }, + { + "text": "to run a function in JavaScript just as", + "start": 463.85, + "duration": 3.42 + }, + { + "text": "you ran a function with Python you use", + "start": 465.53, + "duration": 3.81 + }, + { + "text": "the name of the function followed by a", + "start": 467.27, + "duration": 3.81 + }, + { + "text": "set of parentheses to say go ahead and", + "start": 469.34, + "duration": 3.75 + }, + { + "text": "actually run this function using this", + "start": 471.08, + "duration": 3.93 + }, + { + "text": "parenthesis calls the function another", + "start": 473.09, + "duration": 3.54 + }, + { + "text": "word for running the function and the", + "start": 475.01, + "duration": 2.97 + }, + { + "text": "fact that there's nothing in between the", + "start": 476.63, + "duration": 2.82 + }, + { + "text": "parentheses means we're not providing", + "start": 477.98, + "duration": 3.63 + }, + { + "text": "anything as input to the hello function", + "start": 479.45, + "duration": 3.72 + }, + { + "text": "though if the hello function did take", + "start": 481.61, + "duration": 3.6 + }, + { + "text": "inputs we could certainly add that in", + "start": 483.17, + "duration": 5.46 + }, + { + "text": "between the parentheses so now I've tied", + "start": 485.21, + "duration": 5.31 + }, + { + "text": "the two pieces of this page together I", + "start": 488.63, + "duration": 3.69 + }, + { + "text": "have a button that says click here and", + "start": 490.52, + "duration": 4.62 + }, + { + "text": "I've added an onclick handler that says", + "start": 492.32, + "duration": 4.26 + }, + { + "text": "that when you click on the button you", + "start": 495.14, + "duration": 4.05 + }, + { + "text": "should run the hello function and then", + "start": 496.58, + "duration": 4.14 + }, + { + "text": "up above I've defined the hello function", + "start": 499.19, + "duration": 3.54 + }, + { + "text": "to say what should the hello function do", + "start": 500.72, + "duration": 3.93 + }, + { + "text": "well when the function is called we're", + "start": 502.73, + "duration": 3.57 + }, + { + "text": "going to display an alert that in this", + "start": 504.65, + "duration": 4.56 + }, + { + "text": "case says hello world so now we should", + "start": 506.3, + "duration": 6.63 + }, + { + "text": "be able to refresh the page we still see", + "start": 509.21, + "duration": 5.22 + }, + { + "text": "the same thing at least initially where", + "start": 512.93, + "duration": 2.85 + }, + { + "text": "it just says hello and a button that", + "start": 514.43, + "duration": 4.2 + }, + { + "text": "tells me to click here but now if I go", + "start": 515.78, + "duration": 3.93 + }, + { + "text": "ahead and click the button that says", + "start": 518.63, + "duration": 3.57 + }, + { + "text": "click here well then I get the alert", + "start": 519.71, + "duration": 4.74 + }, + { + "text": "that says this page says hello world I", + "start": 522.2, + "duration": 4.38 + }, + { + "text": "can press ok and this event handler is", + "start": 524.45, + "duration": 3.36 + }, + { + "text": "always going to work I click the button", + "start": 526.58, + "duration": 3.24 + }, + { + "text": "again and I get the alert a second time", + "start": 527.81, + "duration": 3.24 + }, + { + "text": "because every time I click the button", + "start": 529.82, + "duration": 2.94 + }, + { + "text": "it's going to call the hello function", + "start": 531.05, + "duration": 3.66 + }, + { + "text": "again and when I click the hello when", + "start": 532.76, + "duration": 3.69 + }, + { + "text": "the hello function runs and it is going", + "start": 534.71, + "duration": 5.4 + }, + { + "text": "to display this particular alert so this", + "start": 536.45, + "duration": 5.85 + }, + { + "text": "now appears to give us a fair amount of", + "start": 540.11, + "duration": 4.68 + }, + { + "text": "power and much as in other programming", + "start": 542.3, + "duration": 4.35 + }, + { + "text": "languages languages like Python or other", + "start": 544.79, + "duration": 3.03 + }, + { + "text": "languages you might have worked with", + "start": 546.65, + "duration": 3.39 + }, + { + "text": "JavaScript has all these same types of", + "start": 547.82, + "duration": 3.8 + }, + { + "text": "language features so far", + "start": 550.04, + "duration": 3.41 + }, + { + "text": "we've seen datatypes things like a", + "start": 551.62, + "duration": 3.51 + }, + { + "text": "string but we also have other data types", + "start": 553.45, + "duration": 3.33 + }, + { + "text": "that we'll take a look at soon too we've", + "start": 555.13, + "duration": 3.48 + }, + { + "text": "seen functions some functions that are", + "start": 556.78, + "duration": 3.6 + }, + { + "text": "built into JavaScript like the alert", + "start": 558.61, + "duration": 3.66 + }, + { + "text": "function and other functions that we can", + "start": 560.38, + "duration": 3.51 + }, + { + "text": "write for ourselves functions like hello", + "start": 562.27, + "duration": 3.63 + }, + { + "text": "but we also have the ability to include", + "start": 563.89, + "duration": 4.83 + }, + { + "text": "things like variables inside of our", + "start": 565.9, + "duration": 5.1 + }, + { + "text": "program as well so what might that look", + "start": 568.72, + "duration": 2.61 + }, + { + "text": "like", + "start": 571.0, + "duration": 2.31 + }, + { + "text": "well I'll go ahead and create a new file", + "start": 571.33, + "duration": 5.82 + }, + { + "text": "it will call counter HTML and counter is", + "start": 573.31, + "duration": 5.4 + }, + { + "text": "going to have some of the similar code", + "start": 577.15, + "duration": 2.79 + }, + { + "text": "to hello so I'll just go ahead and copy", + "start": 578.71, + "duration": 3.27 + }, + { + "text": "it for now but I'll clear out the script", + "start": 579.94, + "duration": 4.02 + }, + { + "text": "section change the title from hello to", + "start": 581.98, + "duration": 6.51 + }, + { + "text": "counter and now inside I'll get rid of", + "start": 583.96, + "duration": 6.03 + }, + { + "text": "the button or actually I'll keep the", + "start": 588.49, + "duration": 3.69 + }, + { + "text": "button but instead of saying click here", + "start": 589.99, + "duration": 5.19 + }, + { + "text": "the button is going to say count I'd", + "start": 592.18, + "duration": 4.14 + }, + { + "text": "like to create a program that just", + "start": 595.18, + "duration": 3.12 + }, + { + "text": "counts for me from zero to one two two", + "start": 596.32, + "duration": 5.76 + }, + { + "text": "three four so on and so forth and now in", + "start": 598.3, + "duration": 6.0 + }, + { + "text": "order to do that in order to have some", + "start": 602.08, + "duration": 4.23 + }, + { + "text": "way of counting repeatedly zero one two", + "start": 604.3, + "duration": 4.68 + }, + { + "text": "three four five I'm going to need a have", + "start": 606.31, + "duration": 4.38 + }, + { + "text": "some sort of variable inside of my", + "start": 608.98, + "duration": 3.21 + }, + { + "text": "program something that is keeping track", + "start": 610.69, + "duration": 3.69 + }, + { + "text": "of data like the number that I'm", + "start": 612.19, + "duration": 4.35 + }, + { + "text": "currently have counted to so in order to", + "start": 614.38, + "duration": 3.87 + }, + { + "text": "do that in JavaScript I can say", + "start": 616.54, + "duration": 5.07 + }, + { + "text": "something like let counter equal zero", + "start": 618.25, + "duration": 5.76 + }, + { + "text": "this is the way in JavaScript that I", + "start": 621.61, + "duration": 5.07 + }, + { + "text": "define a new variable I first say let", + "start": 624.01, + "duration": 4.68 + }, + { + "text": "counter meaning let there be a new", + "start": 626.68, + "duration": 4.14 + }, + { + "text": "variable called counter and I'm going to", + "start": 628.69, + "duration": 4.17 + }, + { + "text": "initially set the value of counter equal", + "start": 630.82, + "duration": 5.01 + }, + { + "text": "to the number zero and now when I click", + "start": 632.86, + "duration": 4.65 + }, + { + "text": "on the button instead of running the", + "start": 635.83, + "duration": 3.72 + }, + { + "text": "hello function I'm going to go ahead and", + "start": 637.51, + "duration": 4.95 + }, + { + "text": "run the count function which doesn't", + "start": 639.55, + "duration": 4.95 + }, + { + "text": "exist yet but I'll now write it I'll", + "start": 642.46, + "duration": 5.43 + }, + { + "text": "define a function called count and what", + "start": 644.5, + "duration": 6.06 + }, + { + "text": "the count function is going to do is it", + "start": 647.89, + "duration": 5.28 + }, + { + "text": "is going to first increment the value of", + "start": 650.56, + "duration": 4.26 + }, + { + "text": "counter and a number of ways I could do", + "start": 653.17, + "duration": 3.36 + }, + { + "text": "that one is my saying counter equals", + "start": 654.82, + "duration": 4.98 + }, + { + "text": "counter plus one to say go ahead and", + "start": 656.53, + "duration": 4.53 + }, + { + "text": "reset the value of counter to whatever", + "start": 659.8, + "duration": 3.48 + }, + { + "text": "it counter is plus one and there are a", + "start": 661.06, + "duration": 3.78 + }, + { + "text": "couple of shorthand notations for this I", + "start": 663.28, + "duration": 3.72 + }, + { + "text": "could equivalently say counter plus", + "start": 664.84, + "duration": 4.38 + }, + { + "text": "equals one to say add one to the counter", + "start": 667.0, + "duration": 5.04 + }, + { + "text": "or in the case of adding one javascript", + "start": 669.22, + "duration": 4.2 + }, + { + "text": "much like languages like c if you've", + "start": 672.04, + "duration": 3.09 + }, + { + "text": "seen them before and support notation", + "start": 673.42, + "duration": 4.02 + }, + { + "text": "like this counter plus plus which just", + "start": 675.13, + "duration": 3.75 + }, + { + "text": "means take the value of counter and", + "start": 677.44, + "duration": 2.88 + }, + { + "text": "increment it add 1 to it", + "start": 678.88, + "duration": 3.78 + }, + { + "text": "so I'll add 1 to the value of counter", + "start": 680.32, + "duration": 4.98 + }, + { + "text": "and then I'll just display an alert", + "start": 682.66, + "duration": 5.46 + }, + { + "text": "that has whatever the current value of", + "start": 685.3, + "duration": 6.06 + }, + { + "text": "counter happens to be and so I've", + "start": 688.12, + "duration": 4.77 + }, + { + "text": "incremented the value of counter and", + "start": 691.36, + "duration": 3.75 + }, + { + "text": "then displayed an alert that shows me", + "start": 692.89, + "duration": 4.199 + }, + { + "text": "what's contained inside of counter and", + "start": 695.11, + "duration": 6.419 + }, + { + "text": "so now if I go ahead and not go to hello", + "start": 697.089, + "duration": 6.661 + }, + { + "text": "dot HTML but to counter dot HTML instead", + "start": 701.529, + "duration": 5.31 + }, + { + "text": "I now see that I still see a button that", + "start": 703.75, + "duration": 4.829 + }, + { + "text": "says count and if I click on that button", + "start": 706.839, + "duration": 4.351 + }, + { + "text": "I get an alert that this time says one", + "start": 708.579, + "duration": 4.38 + }, + { + "text": "we've incrementing the value of counter", + "start": 711.19, + "duration": 3.99 + }, + { + "text": "from zero to one the alert now says 1", + "start": 712.959, + "duration": 4.62 + }, + { + "text": "and I can press ok if I press count", + "start": 715.18, + "duration": 5.61 + }, + { + "text": "again the count now goes to 2 I press ok", + "start": 717.579, + "duration": 5.581 + }, + { + "text": "press count again it goes to 3 and every", + "start": 720.79, + "duration": 3.87 + }, + { + "text": "time I click count it is going to", + "start": 723.16, + "duration": 3.72 + }, + { + "text": "increment the value of the variable", + "start": 724.66, + "duration": 4.619 + }, + { + "text": "counter inside of my JavaScript webpage", + "start": 726.88, + "duration": 4.26 + }, + { + "text": "and then it's going to display an alert", + "start": 729.279, + "duration": 4.261 + }, + { + "text": "that is going to contain the value of", + "start": 731.14, + "duration": 3.21 + }, + { + "text": "that variable", + "start": 733.54, + "duration": 3.03 + }, + { + "text": "so using alerts now we're able to", + "start": 734.35, + "duration": 3.66 + }, + { + "text": "manipulate that we can inside a", + "start": 736.57, + "duration": 2.82 + }, + { + "text": "functions manipulate the values of", + "start": 738.01, + "duration": 3.24 + }, + { + "text": "variables and then display alerts that", + "start": 739.39, + "duration": 3.9 + }, + { + "text": "show the contents of those variable ism", + "start": 741.25, + "duration": 3.779 + }, + { + "text": "but ultimately when users are", + "start": 743.29, + "duration": 3.57 + }, + { + "text": "interacting with the page it's going to", + "start": 745.029, + "duration": 3.661 + }, + { + "text": "be fairly annoying if the only way that", + "start": 746.86, + "duration": 4.289 + }, + { + "text": "we have to interact with the user is via", + "start": 748.69, + "duration": 4.17 + }, + { + "text": "displaying these alerts the equivalent", + "start": 751.149, + "duration": 3.151 + }, + { + "text": "of like printing something out except", + "start": 752.86, + "duration": 2.969 + }, + { + "text": "instead of printing it to a terminal", + "start": 754.3, + "duration": 3.51 + }, + { + "text": "we're printing it via an alert that", + "start": 755.829, + "duration": 3.901 + }, + { + "text": "appears on the screen what would be more", + "start": 757.81, + "duration": 3.57 + }, + { + "text": "interesting and more powerful and much", + "start": 759.73, + "duration": 3.21 + }, + { + "text": "more useful in the context of a webpage", + "start": 761.38, + "duration": 4.5 + }, + { + "text": "is if we could programmatically update", + "start": 762.94, + "duration": 4.889 + }, + { + "text": "the website change something about the", + "start": 765.88, + "duration": 3.57 + }, + { + "text": "webpage the user is actually seeing", + "start": 767.829, + "duration": 4.111 + }, + { + "text": "changing the content that happens to be", + "start": 769.45, + "duration": 4.71 + }, + { + "text": "on the page and turns out Java Script is", + "start": 771.94, + "duration": 3.69 + }, + { + "text": "going to enable us to do that as well", + "start": 774.16, + "duration": 3.419 + }, + { + "text": "because Java Script allows us to", + "start": 775.63, + "duration": 4.23 + }, + { + "text": "manipulate the Dom the document object", + "start": 777.579, + "duration": 4.231 + }, + { + "text": "model that represents all of the", + "start": 779.86, + "duration": 4.28 + }, + { + "text": "elements that happen to be on that page", + "start": 781.81, + "duration": 5.339 + }, + { + "text": "so to do that let's go ahead and return", + "start": 784.14, + "duration": 6.91 + }, + { + "text": "to hello HTML this again was this paté", + "start": 787.149, + "duration": 6.031 + }, + { + "text": "web page that just said hello and gave", + "start": 791.05, + "duration": 3.69 + }, + { + "text": "me a button where if I clicked on that", + "start": 793.18, + "duration": 3.779 + }, + { + "text": "button it would display an alert that", + "start": 794.74, + "duration": 4.98 + }, + { + "text": "said hello world now what I'd like to do", + "start": 796.959, + "duration": 5.391 + }, + { + "text": "is instead of having the hello function", + "start": 799.72, + "duration": 5.309 + }, + { + "text": "display an alert I'd like to have it", + "start": 802.35, + "duration": 4.989 + }, + { + "text": "manipulate something on the page and", + "start": 805.029, + "duration": 4.291 + }, + { + "text": "what might I want me to manipulate well", + "start": 807.339, + "duration": 4.081 + }, + { + "text": "inside the body of the page I here have", + "start": 809.32, + "duration": 3.9 + }, + { + "text": "this heading this heading that just says", + "start": 811.42, + "duration": 4.26 + }, + { + "text": "hello for example which is inside of an", + "start": 813.22, + "duration": 4.65 + }, + { + "text": "h1 element and what I might like to do", + "start": 815.68, + "duration": 3.63 + }, + { + "text": "is actually change", + "start": 817.87, + "duration": 4.5 + }, + { + "text": "that element how can I do that well it", + "start": 819.31, + "duration": 4.86 + }, + { + "text": "turns out that in JavaScript we have", + "start": 822.37, + "duration": 4.71 + }, + { + "text": "access to a function called document dot", + "start": 824.17, + "duration": 6.42 + }, + { + "text": "query selector and what document query", + "start": 827.08, + "duration": 5.46 + }, + { + "text": "selector is going to do is it is going", + "start": 830.59, + "duration": 4.11 + }, + { + "text": "to give us the ability to look through", + "start": 832.54, + "duration": 5.37 + }, + { + "text": "an HTML page and extract an element out", + "start": 834.7, + "duration": 4.92 + }, + { + "text": "of that page so that we can manipulate", + "start": 837.91, + "duration": 4.95 + }, + { + "text": "that HTML element using JavaScript code", + "start": 839.62, + "duration": 5.88 + }, + { + "text": "and so if I want to select like an h1", + "start": 842.86, + "duration": 4.979 + }, + { + "text": "element I can say document query", + "start": 845.5, + "duration": 4.5 + }, + { + "text": "selector and then as the argument the", + "start": 847.839, + "duration": 3.901 + }, + { + "text": "input to document our query selector", + "start": 850.0, + "duration": 4.68 + }, + { + "text": "I'll go ahead and say each one meaning", + "start": 851.74, + "duration": 5.94 + }, + { + "text": "go through the page find me an h1", + "start": 854.68, + "duration": 4.62 + }, + { + "text": "element and query selector is only going", + "start": 857.68, + "duration": 3.0 + }, + { + "text": "to return one element so if they're", + "start": 859.3, + "duration": 2.61 + }, + { + "text": "multiple it's going to return the first", + "start": 860.68, + "duration": 3.33 + }, + { + "text": "thing it finds but here we only have one", + "start": 861.91, + "duration": 4.11 + }, + { + "text": "h1 element so it's ok I'm gonna say look", + "start": 864.01, + "duration": 4.8 + }, + { + "text": "through this document try and find in h1", + "start": 866.02, + "duration": 5.13 + }, + { + "text": "element and when you do I'd like to", + "start": 868.81, + "duration": 4.08 + }, + { + "text": "manipulate it and the way I'd like to", + "start": 871.15, + "duration": 5.64 + }, + { + "text": "manipulate it is by saying dot innerhtml", + "start": 872.89, + "duration": 8.36 + }, + { + "text": "equals of let's say goodbye for example", + "start": 876.79, + "duration": 7.41 + }, + { + "text": "so alright what's going on here well", + "start": 881.25, + "duration": 4.75 + }, + { + "text": "right now initially when we first load", + "start": 884.2, + "duration": 3.99 + }, + { + "text": "the page we have an h1 a big heading at", + "start": 886.0, + "duration": 4.53 + }, + { + "text": "the top that just says hello and now", + "start": 888.19, + "duration": 4.29 + }, + { + "text": "when this hello function is called which", + "start": 890.53, + "duration": 3.54 + }, + { + "text": "is called when this button is clicked on", + "start": 892.48, + "duration": 3.12 + }, + { + "text": "because it has an on-click attribute", + "start": 894.07, + "duration": 3.93 + }, + { + "text": "that is equal to hello calling the hello", + "start": 895.6, + "duration": 4.41 + }, + { + "text": "function what the hello function is", + "start": 898.0, + "duration": 3.6 + }, + { + "text": "going to do is it's going to say", + "start": 900.01, + "duration": 4.829 + }, + { + "text": "document query selector h1 find me the", + "start": 901.6, + "duration": 6.78 + }, + { + "text": "h1 element that will return this element", + "start": 904.839, + "duration": 5.671 + }, + { + "text": "right here a JavaScript representation", + "start": 908.38, + "duration": 4.77 + }, + { + "text": "of this HTML element that is just an h1", + "start": 910.51, + "duration": 5.85 + }, + { + "text": "whose HTML inside of it says hello and", + "start": 913.15, + "duration": 6.24 + }, + { + "text": "if I want to change that HTML I can do", + "start": 916.36, + "duration": 5.24 + }, + { + "text": "that by modifying the inner HTML", + "start": 919.39, + "duration": 5.64 + }, + { + "text": "property of the JavaScript elephant in", + "start": 921.6, + "duration": 5.29 + }, + { + "text": "order to update a property of anything", + "start": 925.03, + "duration": 3.72 + }, + { + "text": "in JavaScript will generally use this", + "start": 926.89, + "duration": 4.02 + }, + { + "text": "dot notation we're dot accesses of", + "start": 928.75, + "duration": 4.56 + }, + { + "text": "property of some particular object and", + "start": 930.91, + "duration": 4.619 + }, + { + "text": "so I have this element this h1 and", + "start": 933.31, + "duration": 5.04 + }, + { + "text": "saying dot inner HTML means take that", + "start": 935.529, + "duration": 4.741 + }, + { + "text": "element and access its inner HTML", + "start": 938.35, + "duration": 4.05 + }, + { + "text": "property some property of that object", + "start": 940.27, + "duration": 4.259 + }, + { + "text": "and I would like to update its inner", + "start": 942.4, + "duration": 4.83 + }, + { + "text": "HTML to just in this case be the word", + "start": 944.529, + "duration": 4.741 + }, + { + "text": "goodbye followed by an exclamation point", + "start": 947.23, + "duration": 3.32 + }, + { + "text": "for example", + "start": 949.27, + "duration": 3.8 + }, + { + "text": "so now what we'll see is that when we", + "start": 950.55, + "duration": 4.95 + }, + { + "text": "run this page when we open this page up", + "start": 953.07, + "duration": 6.36 + }, + { + "text": "as by opening up hello HTML I still see", + "start": 955.5, + "duration": 5.73 + }, + { + "text": "an h1 that says hello I still see a", + "start": 959.43, + "duration": 4.86 + }, + { + "text": "button that says click here but now when", + "start": 961.23, + "duration": 4.62 + }, + { + "text": "I actually click on the button click", + "start": 964.29, + "duration": 4.229 + }, + { + "text": "here you'll see that hello changes to", + "start": 965.85, + "duration": 3.179 + }, + { + "text": "goodbye", + "start": 968.519, + "duration": 3.031 + }, + { + "text": "we've run JavaScript code that finds an", + "start": 969.029, + "duration": 4.56 + }, + { + "text": "h1 element on the page and manipulates", + "start": 971.55, + "duration": 4.32 + }, + { + "text": "it changing it to something else than it", + "start": 973.589, + "duration": 4.411 + }, + { + "text": "was originally now every time I click", + "start": 975.87, + "duration": 4.68 + }, + { + "text": "here nothing else happens because every", + "start": 978.0, + "duration": 4.35 + }, + { + "text": "time I click here it's going to find the", + "start": 980.55, + "duration": 3.96 + }, + { + "text": "same h1 and it's going to update its", + "start": 982.35, + "duration": 5.07 + }, + { + "text": "HTML changing it from hello to goodbye", + "start": 984.51, + "duration": 5.16 + }, + { + "text": "so maybe what I'd really like then is", + "start": 987.42, + "duration": 4.77 + }, + { + "text": "the ability to toggle back and forth to", + "start": 989.67, + "duration": 4.349 + }, + { + "text": "toggle back and forth between hello and", + "start": 992.19, + "duration": 3.209 + }, + { + "text": "goodbye rather than just change it from", + "start": 994.019, + "duration": 3.661 + }, + { + "text": "one thing to something else every time I", + "start": 995.399, + "duration": 3.331 + }, + { + "text": "click the button I'd like it to", + "start": 997.68, + "duration": 3.3 + }, + { + "text": "alternate back and forth and there are a", + "start": 998.73, + "duration": 3.479 + }, + { + "text": "number of ways you can imagine doing", + "start": 1000.98, + "duration": 3.299 + }, + { + "text": "this but one way is by taking advantage", + "start": 1002.209, + "duration": 4.081 + }, + { + "text": "of conditions so much in the same way", + "start": 1004.279, + "duration": 3.541 + }, + { + "text": "that a language like Python has", + "start": 1006.29, + "duration": 3.83 + }, + { + "text": "conditions ifs and LS and else's", + "start": 1007.82, + "duration": 5.34 + }, + { + "text": "JavaScript too has if and else if and", + "start": 1010.12, + "duration": 5.339 + }, + { + "text": "else that allow us to describe", + "start": 1013.16, + "duration": 4.83 + }, + { + "text": "conditions such that we can only run", + "start": 1015.459, + "duration": 4.721 + }, + { + "text": "certain blocks of code when a particular", + "start": 1017.99, + "duration": 4.67 + }, + { + "text": "boolean expression is true for example", + "start": 1020.18, + "duration": 5.07 + }, + { + "text": "so what would that look like well let's", + "start": 1022.66, + "duration": 4.63 + }, + { + "text": "go ahead and say inside of this hello", + "start": 1025.25, + "duration": 5.78 + }, + { + "text": "function I can ask a question if", + "start": 1027.29, + "duration": 7.86 + }, + { + "text": "document query selector H ones inner", + "start": 1031.03, + "duration": 11.62 + }, + { + "text": "HTML is equal to hello well then go", + "start": 1035.15, + "duration": 11.33 + }, + { + "text": "ahead and set it to goodbye and else", + "start": 1042.65, + "duration": 6.54 + }, + { + "text": "then go ahead and update the inner HTML", + "start": 1046.48, + "duration": 6.09 + }, + { + "text": "this h1 element go ahead and set it to", + "start": 1049.19, + "duration": 7.35 + }, + { + "text": "hello instead so what is this hello", + "start": 1052.57, + "duration": 5.32 + }, + { + "text": "function doing it's now a little bit", + "start": 1056.54, + "duration": 2.22 + }, + { + "text": "more sophisticated", + "start": 1057.89, + "duration": 2.97 + }, + { + "text": "it now has a condition where I say if", + "start": 1058.76, + "duration": 4.14 + }, + { + "text": "the keyword if followed by in", + "start": 1060.86, + "duration": 4.199 + }, + { + "text": "parentheses the condition that I want to", + "start": 1062.9, + "duration": 3.6 + }, + { + "text": "check for the thing I want to see is", + "start": 1065.059, + "duration": 3.511 + }, + { + "text": "this true or not and what I'm checking", + "start": 1066.5, + "duration": 5.309 + }, + { + "text": "for is is let me run document out query", + "start": 1068.57, + "duration": 5.58 + }, + { + "text": "selector h1 which again looks through", + "start": 1071.809, + "duration": 5.131 + }, + { + "text": "the page finds me the h1 tag and get to", + "start": 1074.15, + "duration": 4.89 + }, + { + "text": "that element for me if I look at that", + "start": 1076.94, + "duration": 5.52 + }, + { + "text": "inner HTML if it is equal to hello then", + "start": 1079.04, + "duration": 5.31 + }, + { + "text": "I want to do something and this triple", + "start": 1082.46, + "duration": 2.52 + }, + { + "text": "equals sign", + "start": 1084.35, + "duration": 2.52 + }, + { + "text": "is JavaScript's way of checking for", + "start": 1084.98, + "duration": 3.6 + }, + { + "text": "strict equality checking to make sure", + "start": 1086.87, + "duration": 4.23 + }, + { + "text": "the two values are equal and also that", + "start": 1088.58, + "duration": 4.29 + }, + { + "text": "their types are the same thing that if", + "start": 1091.1, + "duration": 3.72 + }, + { + "text": "this is a string this must also be a", + "start": 1092.87, + "duration": 3.78 + }, + { + "text": "string it turns out in JavaScript is", + "start": 1094.82, + "duration": 3.45 + }, + { + "text": "also a weaker way to check for equality", + "start": 1096.65, + "duration": 4.62 + }, + { + "text": "that just uses two equal signs and that", + "start": 1098.27, + "duration": 5.25 + }, + { + "text": "is going to check the values are the", + "start": 1101.27, + "duration": 4.17 + }, + { + "text": "same but it's going to allow for a bit", + "start": 1103.52, + "duration": 4.41 + }, + { + "text": "of differences in type the two things", + "start": 1105.44, + "duration": 4.11 + }, + { + "text": "might have different types but so long", + "start": 1107.93, + "duration": 3.45 + }, + { + "text": "as they're basically the same value the", + "start": 1109.55, + "duration": 3.36 + }, + { + "text": "double equal sign might generally come", + "start": 1111.38, + "duration": 4.23 + }, + { + "text": "to be true usually if you can you'll", + "start": 1112.91, + "duration": 4.53 + }, + { + "text": "want to use this triple equal sign the", + "start": 1115.61, + "duration": 3.75 + }, + { + "text": "strict equality to make sure that not", + "start": 1117.44, + "duration": 3.21 + }, + { + "text": "only are the types the same but the", + "start": 1119.36, + "duration": 3.12 + }, + { + "text": "values are the same too and the triple", + "start": 1120.65, + "duration": 3.06 + }, + { + "text": "equal sign will check both of those", + "start": 1122.48, + "duration": 4.38 + }, + { + "text": "things so if I go ahead and find the h1", + "start": 1123.71, + "duration": 5.4 + }, + { + "text": "element and its inner HTML is the word", + "start": 1126.86, + "duration": 5.25 + }, + { + "text": "hello well then go ahead and find the h1", + "start": 1129.11, + "duration": 4.79 + }, + { + "text": "element and update its inner HTML", + "start": 1132.11, + "duration": 4.95 + }, + { + "text": "setting it equal to goodbye for example", + "start": 1133.9, + "duration": 6.64 + }, + { + "text": "and else go ahead and find that same h1", + "start": 1137.06, + "duration": 6.06 + }, + { + "text": "element updated inner HTML set it equal", + "start": 1140.54, + "duration": 5.19 + }, + { + "text": "to hello and again just as in functions", + "start": 1143.12, + "duration": 4.14 + }, + { + "text": "where we use these curly braces to", + "start": 1145.73, + "duration": 3.69 + }, + { + "text": "enclose the body of the function all of", + "start": 1147.26, + "duration": 3.78 + }, + { + "text": "the lines of code that are inside of the", + "start": 1149.42, + "duration": 3.6 + }, + { + "text": "function JavaScript does the same thing", + "start": 1151.04, + "duration": 3.96 + }, + { + "text": "to that inside of a condition when we", + "start": 1153.02, + "duration": 3.93 + }, + { + "text": "want to express that this is inside the", + "start": 1155.0, + "duration": 4.17 + }, + { + "text": "body of an if condition I can use curly", + "start": 1156.95, + "duration": 4.23 + }, + { + "text": "braces to say this line of code in that", + "start": 1159.17, + "duration": 3.78 + }, + { + "text": "line of code that's inside of the if", + "start": 1161.18, + "duration": 3.84 + }, + { + "text": "expression or that's inside of the else", + "start": 1162.95, + "duration": 5.04 + }, + { + "text": "expression for example so let's go ahead", + "start": 1165.02, + "duration": 4.47 + }, + { + "text": "and try this now I can go ahead and open", + "start": 1167.99, + "duration": 3.29 + }, + { + "text": "hello dot HTML", + "start": 1169.49, + "duration": 4.26 + }, + { + "text": "refresh it it currently says hello with", + "start": 1171.28, + "duration": 5.25 + }, + { + "text": "a button that says click here and now", + "start": 1173.75, + "duration": 5.79 + }, + { + "text": "when I click here hello changes to", + "start": 1176.53, + "duration": 5.2 + }, + { + "text": "goodbye and when I click here again", + "start": 1179.54, + "duration": 4.5 + }, + { + "text": "goodbye changes back to hello and every", + "start": 1181.73, + "duration": 3.99 + }, + { + "text": "time I click the button it's going to", + "start": 1184.04, + "duration": 3.06 + }, + { + "text": "alternate between hello and goodbye", + "start": 1185.72, + "duration": 3.24 + }, + { + "text": "because we either get caught in the if", + "start": 1187.1, + "duration": 4.35 + }, + { + "text": "expression or we get caught in the else", + "start": 1188.96, + "duration": 5.19 + }, + { + "text": "expression now there are a couple of", + "start": 1191.45, + "duration": 3.93 + }, + { + "text": "places where you might look at this and", + "start": 1194.15, + "duration": 2.73 + }, + { + "text": "notice that maybe this isn't as", + "start": 1195.38, + "duration": 3.45 + }, + { + "text": "efficient as this code could potentially", + "start": 1196.88, + "duration": 4.08 + }, + { + "text": "be and recall that every time we run", + "start": 1198.83, + "duration": 4.77 + }, + { + "text": "document query selector to say go ahead", + "start": 1200.96, + "duration": 4.2 + }, + { + "text": "and try and find a particular HTML", + "start": 1203.6, + "duration": 4.17 + }, + { + "text": "element for me it's going to look", + "start": 1205.16, + "duration": 4.53 + }, + { + "text": "through that page trying to find the h1", + "start": 1207.77, + "duration": 3.63 + }, + { + "text": "element and it turns out that right now", + "start": 1209.69, + "duration": 4.17 + }, + { + "text": "we have three separate calls to query", + "start": 1211.4, + "duration": 3.99 + }, + { + "text": "selector even though only two of them", + "start": 1213.86, + "duration": 3.0 + }, + { + "text": "will ever run on any given instance of", + "start": 1215.39, + "duration": 2.66 + }, + { + "text": "the function but we", + "start": 1216.86, + "duration": 3.23 + }, + { + "text": "document a query selector then we call", + "start": 1218.05, + "duration": 4.56 + }, + { + "text": "it again inside of the if expression we", + "start": 1220.09, + "duration": 4.53 + }, + { + "text": "can probably improve the design of this", + "start": 1222.61, + "duration": 4.44 + }, + { + "text": "page by factoring that out by just", + "start": 1224.62, + "duration": 4.65 + }, + { + "text": "looking for the h1 element once and then", + "start": 1227.05, + "duration": 4.41 + }, + { + "text": "manipulating it and checking it using", + "start": 1229.27, + "duration": 4.5 + }, + { + "text": "that element that we have found and to", + "start": 1231.46, + "duration": 4.38 + }, + { + "text": "do that we can store an element inside", + "start": 1233.77, + "duration": 3.72 + }, + { + "text": "of a variable in the same way that a", + "start": 1235.84, + "duration": 3.72 + }, + { + "text": "variable can store a number like a", + "start": 1237.49, + "duration": 4.35 + }, + { + "text": "counter or a string like hello world it", + "start": 1239.56, + "duration": 4.68 + }, + { + "text": "can also store other values like an HTML", + "start": 1241.84, + "duration": 5.04 + }, + { + "text": "element that we get back from document", + "start": 1244.24, + "duration": 4.77 + }, + { + "text": "dog query selector so I could say", + "start": 1246.88, + "duration": 6.54 + }, + { + "text": "something like let heading we're heading", + "start": 1249.01, + "duration": 6.63 + }, + { + "text": "is just the name of a variable the equal", + "start": 1253.42, + "duration": 5.85 + }, + { + "text": "to document query selector h1 for", + "start": 1255.64, + "duration": 5.94 + }, + { + "text": "instance find the h1 element save it", + "start": 1259.27, + "duration": 3.84 + }, + { + "text": "inside of a variable called heading and", + "start": 1261.58, + "duration": 4.32 + }, + { + "text": "now rather than document query selector", + "start": 1263.11, + "duration": 4.83 + }, + { + "text": "each one all the time I can just say if", + "start": 1265.9, + "duration": 4.23 + }, + { + "text": "the headings inner HTML is hello", + "start": 1267.94, + "duration": 4.98 + }, + { + "text": "then set the headings inner HTML to good", + "start": 1270.13, + "duration": 3.21 + }, + { + "text": "bye", + "start": 1272.92, + "duration": 2.91 + }, + { + "text": "otherwise I set the headings inner HTML", + "start": 1273.34, + "duration": 3.51 + }, + { + "text": "to hello", + "start": 1275.83, + "duration": 2.46 + }, + { + "text": "so I've improved the efficiency of the", + "start": 1276.85, + "duration": 3.36 + }, + { + "text": "program but also reduce the number of", + "start": 1278.29, + "duration": 3.36 + }, + { + "text": "characters of code that I've had to", + "start": 1280.21, + "duration": 3.0 + }, + { + "text": "write my lines are now much shorter a", + "start": 1281.65, + "duration": 3.39 + }, + { + "text": "little bit easier to read this we would", + "start": 1283.21, + "duration": 4.11 + }, + { + "text": "consider to be an improvement in design", + "start": 1285.04, + "duration": 4.17 + }, + { + "text": "and it turns out there's one other", + "start": 1287.32, + "duration": 4.47 + }, + { + "text": "improvement we can make here too that we", + "start": 1289.21, + "duration": 4.74 + }, + { + "text": "can define a variable like let something", + "start": 1291.79, + "duration": 4.11 + }, + { + "text": "equal something else but it turns out", + "start": 1293.95, + "duration": 3.48 + }, + { + "text": "that JavaScript gives us a couple of", + "start": 1295.9, + "duration": 4.14 + }, + { + "text": "ways to define a variable and if we're", + "start": 1297.43, + "duration": 4.56 + }, + { + "text": "going to be creating a variable whose", + "start": 1300.04, + "duration": 4.38 + }, + { + "text": "value is never going to change we're", + "start": 1301.99, + "duration": 4.26 + }, + { + "text": "never going to reassign the variable", + "start": 1304.42, + "duration": 4.17 + }, + { + "text": "name to something else then instead of", + "start": 1306.25, + "duration": 4.62 + }, + { + "text": "let we can enforce that it's never going", + "start": 1308.59, + "duration": 5.31 + }, + { + "text": "to change by calling it a Const variable", + "start": 1310.87, + "duration": 5.91 + }, + { + "text": "so Const heading equals document query", + "start": 1313.9, + "duration": 5.31 + }, + { + "text": "selector h1 means I am going to create a", + "start": 1316.78, + "duration": 4.44 + }, + { + "text": "variable called heading setting it equal", + "start": 1319.21, + "duration": 4.35 + }, + { + "text": "to the result of document query selector", + "start": 1321.22, + "duration": 5.82 + }, + { + "text": "h1 and never again will I change what", + "start": 1323.56, + "duration": 5.1 + }, + { + "text": "heading is equal to I will never have", + "start": 1327.04, + "duration": 3.0 + }, + { + "text": "another line of code that says heading", + "start": 1328.66, + "duration": 3.63 + }, + { + "text": "equals something else because it is", + "start": 1330.04, + "duration": 3.87 + }, + { + "text": "constant and JavaScript will then", + "start": 1332.29, + "duration": 3.27 + }, + { + "text": "enforce that this variable should not", + "start": 1333.91, + "duration": 3.72 + }, + { + "text": "change and if ever I do try to change it", + "start": 1335.56, + "duration": 3.66 + }, + { + "text": "javascript will give me an error and", + "start": 1337.63, + "duration": 3.84 + }, + { + "text": "this can just be helpful to prevent", + "start": 1339.22, + "duration": 4.14 + }, + { + "text": "against possible unintended behavior", + "start": 1341.47, + "duration": 3.81 + }, + { + "text": "that if you know you have a variable it", + "start": 1343.36, + "duration": 3.69 + }, + { + "text": "is never going to change it's often good", + "start": 1345.28, + "duration": 4.71 + }, + { + "text": "designed to label it as a constable so", + "start": 1347.05, + "duration": 4.29 + }, + { + "text": "that you and other people looking at", + "start": 1349.99, + "duration": 1.75 + }, + { + "text": "your code", + "start": 1351.34, + "duration": 2.41 + }, + { + "text": "know that that is never going to have a", + "start": 1351.74, + "duration": 5.25 + }, + { + "text": "value that gets changed later on so this", + "start": 1353.75, + "duration": 5.7 + }, + { + "text": "then will behave the same way where it", + "start": 1356.99, + "duration": 4.38 + }, + { + "text": "says hello but I can toggle it back and", + "start": 1359.45, + "duration": 4.74 + }, + { + "text": "forth changing it to goodbye and then", + "start": 1361.37, + "duration": 5.67 + }, + { + "text": "changing it back to hello again and so", + "start": 1364.19, + "duration": 4.83 + }, + { + "text": "now using this ability this ability to", + "start": 1367.04, + "duration": 4.019 + }, + { + "text": "manipulate the dawn we can go back to", + "start": 1369.02, + "duration": 4.02 + }, + { + "text": "our counter program and actually improve", + "start": 1371.059, + "duration": 4.471 + }, + { + "text": "upon it that right now the counter", + "start": 1373.04, + "duration": 5.28 + }, + { + "text": "program I count and it displays an alert", + "start": 1375.53, + "duration": 4.59 + }, + { + "text": "that says 1 I count and it displays an", + "start": 1378.32, + "duration": 3.9 + }, + { + "text": "alert that says 2 I can probably do a", + "start": 1380.12, + "duration": 4.23 + }, + { + "text": "little bit better than that by instead", + "start": 1382.22, + "duration": 4.11 + }, + { + "text": "of displaying an alert actually", + "start": 1384.35, + "duration": 4.86 + }, + { + "text": "manipulating the Dom in some way that I", + "start": 1386.33, + "duration": 4.86 + }, + { + "text": "would like to have this h1 this big", + "start": 1389.21, + "duration": 3.81 + }, + { + "text": "heading at the top instead of starting", + "start": 1391.19, + "duration": 3.989 + }, + { + "text": "up by saying hello let's have it start", + "start": 1393.02, + "duration": 5.25 + }, + { + "text": "out by saying 0 for example just some", + "start": 1395.179, + "duration": 5.821 + }, + { + "text": "initial value for the counter and now", + "start": 1398.27, + "duration": 4.26 + }, + { + "text": "when I increment the value of counter", + "start": 1401.0, + "duration": 3.63 + }, + { + "text": "rather than display an alert that just", + "start": 1402.53, + "duration": 3.779 + }, + { + "text": "tells me the value of the counter in an", + "start": 1404.63, + "duration": 4.26 + }, + { + "text": "alert I'm going to instead say document", + "start": 1406.309, + "duration": 7.671 + }, + { + "text": "query selector h1 . innerhtml", + "start": 1408.89, + "duration": 10.05 + }, + { + "text": "equals counter where i'm saying find the", + "start": 1413.98, + "duration": 7.42 + }, + { + "text": "h1 element updated innerhtml", + "start": 1418.94, + "duration": 4.8 + }, + { + "text": "set it equal to whatever the value of", + "start": 1421.4, + "duration": 5.1 + }, + { + "text": "the variable counter happens to be such", + "start": 1423.74, + "duration": 4.86 + }, + { + "text": "that now if i refresh this page the", + "start": 1426.5, + "duration": 3.96 + }, + { + "text": "value of this h1 initially is 0 that's", + "start": 1428.6, + "duration": 3.66 + }, + { + "text": "the initial value but every time I click", + "start": 1430.46, + "duration": 4.05 + }, + { + "text": "count we're going to update the contents", + "start": 1432.26, + "duration": 4.26 + }, + { + "text": "of that h1 element and this time setting", + "start": 1434.51, + "duration": 5.22 + }, + { + "text": "it to 1 2 3 4 and so forth every time I", + "start": 1436.52, + "duration": 4.74 + }, + { + "text": "click the count button it's going to", + "start": 1439.73, + "duration": 3.18 + }, + { + "text": "increment the value of the variable as", + "start": 1441.26, + "duration": 3.93 + }, + { + "text": "well as manipulate the Dom actually", + "start": 1442.91, + "duration": 5.82 + }, + { + "text": "making changes in order to produce the", + "start": 1445.19, + "duration": 5.489 + }, + { + "text": "effect that I want to see on this actual", + "start": 1448.73, + "duration": 5.07 + }, + { + "text": "page and we can begin to add additional", + "start": 1450.679, + "duration": 4.861 + }, + { + "text": "logic to this as well maybe I do", + "start": 1453.8, + "duration": 3.78 + }, + { + "text": "occasionally want an alert but I don't", + "start": 1455.54, + "duration": 3.96 + }, + { + "text": "want an alert every single time I could", + "start": 1457.58, + "duration": 3.39 + }, + { + "text": "add a condition I could say something", + "start": 1459.5, + "duration": 2.94 + }, + { + "text": "like if I only want to display an alert", + "start": 1460.97, + "duration": 3.69 + }, + { + "text": "every time I count to a multiple of 10", + "start": 1462.44, + "duration": 4.29 + }, + { + "text": "like 10 and 20 and 30 and 40 and 50 and", + "start": 1464.66, + "duration": 4.14 + }, + { + "text": "so forth I could add a condition that", + "start": 1466.73, + "duration": 6.06 + }, + { + "text": "says that if counter mod 10 and mod just", + "start": 1468.8, + "duration": 6.09 + }, + { + "text": "gets me remainder when you divide by 10", + "start": 1472.79, + "duration": 3.6 + }, + { + "text": "so if you take the counter divide it by", + "start": 1474.89, + "duration": 4.44 + }, + { + "text": "10 if the remainder is 0 when I divide", + "start": 1476.39, + "duration": 4.919 + }, + { + "text": "by 10 well that means counter is a", + "start": 1479.33, + "duration": 4.2 + }, + { + "text": "multiple of 10 and so I can now display", + "start": 1481.309, + "duration": 4.681 + }, + { + "text": "an alert where I can display annele", + "start": 1483.53, + "duration": 4.529 + }, + { + "text": "that says like I want to say something", + "start": 1485.99, + "duration": 4.53 + }, + { + "text": "like the counter is now 10 or the", + "start": 1488.059, + "duration": 4.651 + }, + { + "text": "counter is now 20 and in order to do", + "start": 1490.52, + "duration": 3.87 + }, + { + "text": "that what I really want to do is have", + "start": 1492.71, + "duration": 5.31 + }, + { + "text": "some way of plugging in a variable into", + "start": 1494.39, + "duration": 6.57 + }, + { + "text": "a string inside of JavaScript and in", + "start": 1498.02, + "duration": 4.53 + }, + { + "text": "Python the way we would have done this", + "start": 1500.96, + "duration": 3.9 + }, + { + "text": "is by you appending f4 prepending F in", + "start": 1502.55, + "duration": 3.629 + }, + { + "text": "front of the string to create a", + "start": 1504.86, + "duration": 3.42 + }, + { + "text": "formatted string and then I would have", + "start": 1506.179, + "duration": 4.621 + }, + { + "text": "said something like the count is now and", + "start": 1508.28, + "duration": 5.22 + }, + { + "text": "then I'd use curly braces to say go", + "start": 1510.8, + "duration": 4.41 + }, + { + "text": "ahead and print out the value of counter", + "start": 1513.5, + "duration": 3.809 + }, + { + "text": "so this f4 formatted string followed by", + "start": 1515.21, + "duration": 3.66 + }, + { + "text": "this string would have been the way in", + "start": 1517.309, + "duration": 2.941 + }, + { + "text": "python that we would have done this", + "start": 1518.87, + "duration": 3.24 + }, + { + "text": "turns out javascript does the same thing", + "start": 1520.25, + "duration": 3.87 + }, + { + "text": "just with slightly different syntax it", + "start": 1522.11, + "duration": 4.98 + }, + { + "text": "doesn't use F instead instead of using", + "start": 1524.12, + "duration": 4.74 + }, + { + "text": "the regular quotation marks whether the", + "start": 1527.09, + "duration": 3.469 + }, + { + "text": "single or double quotation marks", + "start": 1528.86, + "duration": 4.47 + }, + { + "text": "JavaScript uses these backticks", + "start": 1530.559, + "duration": 4.841 + }, + { + "text": "which are usually located above the tab", + "start": 1533.33, + "duration": 5.37 + }, + { + "text": "key on a standard u.s. keyboard and this", + "start": 1535.4, + "duration": 5.01 + }, + { + "text": "is going to create what JavaScript calls", + "start": 1538.7, + "duration": 3.72 + }, + { + "text": "a template literal where I can then", + "start": 1540.41, + "duration": 3.39 + }, + { + "text": "substitute the value of a variable", + "start": 1542.42, + "duration": 3.96 + }, + { + "text": "somewhere inside of this template and", + "start": 1543.8, + "duration": 4.59 + }, + { + "text": "then in order to actually do the", + "start": 1546.38, + "duration": 4.29 + }, + { + "text": "substitution while Python uses double", + "start": 1548.39, + "duration": 4.26 + }, + { + "text": "curly braces to say plug in the value of", + "start": 1550.67, + "duration": 3.9 + }, + { + "text": "counter right here javascript does", + "start": 1552.65, + "duration": 3.54 + }, + { + "text": "something similar it also uses double", + "start": 1554.57, + "duration": 3.3 + }, + { + "text": "curly braces but there needs to be a", + "start": 1556.19, + "duration": 3.36 + }, + { + "text": "dollar sign in front of it the dollar", + "start": 1557.87, + "duration": 3.54 + }, + { + "text": "sign and then the dollar double curly", + "start": 1559.55, + "duration": 3.99 + }, + { + "text": "braces we can go ahead and plug in the", + "start": 1561.41, + "duration": 5.19 + }, + { + "text": "value of a variable there so this then", + "start": 1563.54, + "duration": 5.55 + }, + { + "text": "is a template literal where every time", + "start": 1566.6, + "duration": 4.44 + }, + { + "text": "we get to a multiple of ten we're going", + "start": 1569.09, + "duration": 3.51 + }, + { + "text": "to display an alert that says the count", + "start": 1571.04, + "duration": 4.38 + }, + { + "text": "is now and then this dollar sign curly", + "start": 1572.6, + "duration": 5.1 + }, + { + "text": "brace means actually plug in whatever", + "start": 1575.42, + "duration": 5.009 + }, + { + "text": "the value of counter happens to be right", + "start": 1577.7, + "duration": 5.609 + }, + { + "text": "there so now if I go ahead and refresh", + "start": 1580.429, + "duration": 5.671 + }, + { + "text": "counter it starts at zero I can count 3", + "start": 1583.309, + "duration": 5.671 + }, + { + "text": "4 5 6 7 8 9 but when I get to 10 then I", + "start": 1586.1, + "duration": 4.86 + }, + { + "text": "get an alert that says the count is now", + "start": 1588.98, + "duration": 4.65 + }, + { + "text": "10 and then I see the result update on", + "start": 1590.96, + "duration": 5.25 + }, + { + "text": "the page and so that template literal", + "start": 1593.63, + "duration": 5.07 + }, + { + "text": "can allow us to combine variables and", + "start": 1596.21, + "duration": 4.56 + }, + { + "text": "strings in order to generate new strings", + "start": 1598.7, + "duration": 4.74 + }, + { + "text": "that are able to represent data inside", + "start": 1600.77, + "duration": 6.0 + }, + { + "text": "of them as well so now what improvements", + "start": 1603.44, + "duration": 4.98 + }, + { + "text": "can we begin to make it what changes can", + "start": 1606.77, + "duration": 3.0 + }, + { + "text": "we make to this to improve upon the", + "start": 1608.42, + "duration": 3.3 + }, + { + "text": "design of it well one thing especially", + "start": 1609.77, + "duration": 3.78 + }, + { + "text": "as our programs get a little bit more", + "start": 1611.72, + "duration": 3.089 + }, + { + "text": "sophisticated a little bit more", + "start": 1613.55, + "duration": 3.509 + }, + { + "text": "complicated is that we often don't want", + "start": 1614.809, + "duration": 5.521 + }, + { + "text": "to be intermingling our JavaScript code", + "start": 1617.059, + "duration": 5.401 + }, + { + "text": "with the contents of our HTML the down", + "start": 1620.33, + "duration": 4.14 + }, + { + "text": "here we have button on click equals", + "start": 1622.46, + "duration": 3.87 + }, + { + "text": "count this name of this function and", + "start": 1624.47, + "duration": 3.9 + }, + { + "text": "especially as our page starts to get", + "start": 1626.33, + "duration": 3.93 + }, + { + "text": "more complicated it's going to start to", + "start": 1628.37, + "duration": 3.689 + }, + { + "text": "get a little bit annoying if we're", + "start": 1630.26, + "duration": 3.63 + }, + { + "text": "constantly having to maintain a little", + "start": 1632.059, + "duration": 3.301 + }, + { + "text": "bit of JavaScript code like making a", + "start": 1633.89, + "duration": 3.539 + }, + { + "text": "call to a function inside of our HTML", + "start": 1635.36, + "duration": 3.689 + }, + { + "text": "we'll see a little bit later there are", + "start": 1637.429, + "duration": 3.151 + }, + { + "text": "other paradigms that actually encourage", + "start": 1639.049, + "duration": 3.691 + }, + { + "text": "this type of thing but right now it can", + "start": 1640.58, + "duration": 4.05 + }, + { + "text": "start to get a little poorly designed if", + "start": 1642.74, + "duration": 3.84 + }, + { + "text": "we'd really like to separate all of our", + "start": 1644.63, + "duration": 4.139 + }, + { + "text": "JavaScript related code from all of the", + "start": 1646.58, + "duration": 4.55 + }, + { + "text": "HTML the general structure of our page", + "start": 1648.769, + "duration": 4.77 + }, + { + "text": "and so there are ways we can begin to do", + "start": 1651.13, + "duration": 4.98 + }, + { + "text": "that as well I can add an event listener", + "start": 1653.539, + "duration": 5.88 + }, + { + "text": "inside of JavaScript to that I can say", + "start": 1656.11, + "duration": 7.419 + }, + { + "text": "something like document dot query", + "start": 1659.419, + "duration": 8.911 + }, + { + "text": "selector button and then I can say dot", + "start": 1663.529, + "duration": 10.081 + }, + { + "text": "on click equals count so what's going on", + "start": 1668.33, + "duration": 7.26 + }, + { + "text": "here and I can do this instead of this", + "start": 1673.61, + "duration": 3.96 + }, + { + "text": "on click equals count what I'm now", + "start": 1675.59, + "duration": 4.829 + }, + { + "text": "saying is document query selector button", + "start": 1677.57, + "duration": 5.219 + }, + { + "text": "find me the button on the page and turns", + "start": 1680.419, + "duration": 3.781 + }, + { + "text": "out there's only one button here so it's", + "start": 1682.789, + "duration": 2.64 + }, + { + "text": "fine though if there were more I might", + "start": 1684.2, + "duration": 2.55 + }, + { + "text": "have to be a little bit more specific", + "start": 1685.429, + "duration": 4.23 + }, + { + "text": "but once I get that button then I'm", + "start": 1686.75, + "duration": 4.799 + }, + { + "text": "going to access it's on click property", + "start": 1689.659, + "duration": 4.921 + }, + { + "text": "and I'm going to set it equal to count", + "start": 1691.549, + "duration": 5.73 + }, + { + "text": "and what does count count is the name of", + "start": 1694.58, + "duration": 4.86 + }, + { + "text": "a function count is itself a function", + "start": 1697.279, + "duration": 4.801 + }, + { + "text": "and so what I'm here saying is I would", + "start": 1699.44, + "duration": 4.92 + }, + { + "text": "like to set the value of the onclick", + "start": 1702.08, + "duration": 4.29 + }, + { + "text": "property of the button equal to count", + "start": 1704.36, + "duration": 3.539 + }, + { + "text": "the count is the function that should", + "start": 1706.37, + "duration": 4.95 + }, + { + "text": "run when the button is clicked on and", + "start": 1707.899, + "duration": 5.671 + }, + { + "text": "notice that I am not actually calling", + "start": 1711.32, + "duration": 4.05 + }, + { + "text": "the function it's not count and then", + "start": 1713.57, + "duration": 3.479 + }, + { + "text": "parentheses which were being run the", + "start": 1715.37, + "duration": 3.75 + }, + { + "text": "count function and then get its return", + "start": 1717.049, + "duration": 3.931 + }, + { + "text": "value and use that as the value for", + "start": 1719.12, + "duration": 4.289 + }, + { + "text": "onclick I'm just setting on click equal", + "start": 1720.98, + "duration": 4.949 + }, + { + "text": "literally to the count function itself", + "start": 1723.409, + "duration": 3.87 + }, + { + "text": "without actually calling the function", + "start": 1725.929, + "duration": 3.84 + }, + { + "text": "and what this is going to do is it is", + "start": 1727.279, + "duration": 4.11 + }, + { + "text": "going to say when the button is clicked", + "start": 1729.769, + "duration": 3.931 + }, + { + "text": "on then and only then should you", + "start": 1731.389, + "duration": 4.41 + }, + { + "text": "actually run this count function and", + "start": 1733.7, + "duration": 3.06 + }, + { + "text": "we're not going to run the count", + "start": 1735.799, + "duration": 4.201 + }, + { + "text": "function until that button actually gets", + "start": 1736.76, + "duration": 5.25 + }, + { + "text": "clicked on and so in JavaScript", + "start": 1740.0, + "duration": 4.679 + }, + { + "text": "functions can be treated as values of", + "start": 1742.01, + "duration": 4.799 + }, + { + "text": "their own just as you can set a variable", + "start": 1744.679, + "duration": 3.99 + }, + { + "text": "equal to a string just as even set a", + "start": 1746.809, + "duration": 3.75 + }, + { + "text": "variable equal to an integer just as you", + "start": 1748.669, + "duration": 3.811 + }, + { + "text": "can set a variable equal to like an HTML", + "start": 1750.559, + "duration": 3.601 + }, + { + "text": "element like the result of document", + "start": 1752.48, + "duration": 3.99 + }, + { + "text": "query selector you can also set a", + "start": 1754.16, + "duration": 4.83 + }, + { + "text": "variable equal to a function something", + "start": 1756.47, + "duration": 4.59 + }, + { + "text": "like count and passed that around as a", + "start": 1758.99, + "duration": 4.56 + }, + { + "text": "value just as you could with any other", + "start": 1761.06, + "duration": 3.99 + }, + { + "text": "value and this is a paradigm we", + "start": 1763.55, + "duration": 3.09 + }, + { + "text": "generally call functional programming", + "start": 1765.05, + "duration": 4.35 + }, + { + "text": "where we have functions as values of", + "start": 1766.64, + "duration": 4.14 + }, + { + "text": "their own things that we can reassign", + "start": 1769.4, + "duration": 3.6 + }, + { + "text": "things that we can manipulate just as we", + "start": 1770.78, + "duration": 6.0 + }, + { + "text": "could have any other value so now I can", + "start": 1773.0, + "duration": 5.22 + }, + { + "text": "try and run this program by going ahead", + "start": 1776.78, + "duration": 3.39 + }, + { + "text": "and refreshing the page I'll refresh it", + "start": 1778.22, + "duration": 4.92 + }, + { + "text": "at zero I press count and alright", + "start": 1780.17, + "duration": 4.98 + }, + { + "text": "nothing seems to be happening it's still", + "start": 1783.14, + "duration": 4.32 + }, + { + "text": "zero I want it to be counting but it", + "start": 1785.15, + "duration": 4.35 + }, + { + "text": "doesn't seem to be working so why not", + "start": 1787.46, + "duration": 3.81 + }, + { + "text": "any time you run into problems in", + "start": 1789.5, + "duration": 3.0 + }, + { + "text": "JavaScript where you're not getting the", + "start": 1791.27, + "duration": 2.94 + }, + { + "text": "behavior you want often it can be", + "start": 1792.5, + "duration": 3.21 + }, + { + "text": "helpful to look at the JavaScript", + "start": 1794.21, + "duration": 3.57 + }, + { + "text": "console where the JavaScript console is", + "start": 1795.71, + "duration": 3.84 + }, + { + "text": "the equivalent of like the terminal", + "start": 1797.78, + "duration": 3.0 + }, + { + "text": "window and when you're running your", + "start": 1799.55, + "duration": 3.06 + }, + { + "text": "Django application in Python that would", + "start": 1800.78, + "duration": 3.51 + }, + { + "text": "display any error messages the", + "start": 1802.61, + "duration": 3.69 + }, + { + "text": "JavaScript console will display any of", + "start": 1804.29, + "duration": 3.84 + }, + { + "text": "the JavaScript logging information and", + "start": 1806.3, + "duration": 4.68 + }, + { + "text": "error messages as well in chrome I can", + "start": 1808.13, + "duration": 4.74 + }, + { + "text": "get to it if I first go ahead and go to", + "start": 1810.98, + "duration": 4.86 + }, + { + "text": "inspect and then just open up the", + "start": 1812.87, + "duration": 5.55 + }, + { + "text": "console tab here and all right we seem", + "start": 1815.84, + "duration": 4.2 + }, + { + "text": "to have some sort of error here it's an", + "start": 1818.42, + "duration": 4.59 + }, + { + "text": "uncaught type error that says we cannot", + "start": 1820.04, + "duration": 7.17 + }, + { + "text": "set property on click of no encounter", + "start": 1823.01, + "duration": 7.11 + }, + { + "text": "dot HTML line 18 so that will generally", + "start": 1827.21, + "duration": 4.38 + }, + { + "text": "tell you where the error is coming from", + "start": 1830.12, + "duration": 3.87 + }, + { + "text": "it's coming from counter HTML on line 18", + "start": 1831.59, + "duration": 4.74 + }, + { + "text": "and the problem seems to be but I'm", + "start": 1833.99, + "duration": 4.47 + }, + { + "text": "trying to access the on click property", + "start": 1836.33, + "duration": 5.07 + }, + { + "text": "of no and no is JavaScript way of", + "start": 1838.46, + "duration": 4.89 + }, + { + "text": "expressing like nothing some object that", + "start": 1841.4, + "duration": 5.07 + }, + { + "text": "doesn't exist so somehow I'm trying to", + "start": 1843.35, + "duration": 5.1 + }, + { + "text": "set the onclick property of no well", + "start": 1846.47, + "duration": 3.9 + }, + { + "text": "let's see what's going on on line 18 and", + "start": 1848.45, + "duration": 4.14 + }, + { + "text": "see if we can figure out what's", + "start": 1850.37, + "duration": 2.91 + }, + { + "text": "happening there", + "start": 1852.59, + "duration": 3.24 + }, + { + "text": "well alright here is line 18 where I say", + "start": 1853.28, + "duration": 4.14 + }, + { + "text": "document dot query selector button", + "start": 1855.83, + "duration": 4.08 + }, + { + "text": "setting it's on click property equal to", + "start": 1857.42, + "duration": 4.86 + }, + { + "text": "count and now what seems to be the", + "start": 1859.91, + "duration": 4.32 + }, + { + "text": "problem here well the error message was", + "start": 1862.28, + "duration": 4.26 + }, + { + "text": "that I was trying to modify the onclick", + "start": 1864.23, + "duration": 4.92 + }, + { + "text": "property of no well here then is the", + "start": 1866.54, + "duration": 4.86 + }, + { + "text": "onclick property so why would this", + "start": 1869.15, + "duration": 4.62 + }, + { + "text": "document query selector button be", + "start": 1871.4, + "duration": 4.65 + }, + { + "text": "returning or giving me an output of no", + "start": 1873.77, + "duration": 4.59 + }, + { + "text": "well it turns out the document dot query", + "start": 1876.05, + "duration": 4.35 + }, + { + "text": "selector will return null if it's not", + "start": 1878.36, + "duration": 4.23 + }, + { + "text": "able to find something if I try and find", + "start": 1880.4, + "duration": 4.08 + }, + { + "text": "a button but it's not able to find a", + "start": 1882.59, + "duration": 3.57 + }, + { + "text": "button well this seems a little bit", + "start": 1884.48, + "duration": 3.12 + }, + { + "text": "strange because there's a button down", + "start": 1886.16, + "duration": 1.77 + }, + { + "text": "here", + "start": 1887.6, + "duration": 3.66 + }, + { + "text": "24 that I'd like for my JavaScript code", + "start": 1887.93, + "duration": 5.28 + }, + { + "text": "to be able to find when it runs query", + "start": 1891.26, + "duration": 4.23 + }, + { + "text": "selector and tries to find the button as", + "start": 1893.21, + "duration": 4.08 + }, + { + "text": "it turns out this is a bit of the quirk", + "start": 1895.49, + "duration": 3.09 + }, + { + "text": "of the way the browser is going to work", + "start": 1897.29, + "duration": 3.09 + }, + { + "text": "but if the browser is running our code", + "start": 1898.58, + "duration": 3.66 + }, + { + "text": "from top to bottom just reading it from", + "start": 1900.38, + "duration": 4.08 + }, + { + "text": "line one on and on then it's going to", + "start": 1902.24, + "duration": 4.68 + }, + { + "text": "get to line 18 where I said document", + "start": 1904.46, + "duration": 4.32 + }, + { + "text": "query selector button onclick equals", + "start": 1906.92, + "duration": 4.11 + }, + { + "text": "count and it's going to try and find a", + "start": 1908.78, + "duration": 4.65 + }, + { + "text": "button on line 18 but the button doesn't", + "start": 1911.03, + "duration": 5.01 + }, + { + "text": "show up in my HTML page until much", + "start": 1913.43, + "duration": 4.8 + }, + { + "text": "further down in the page so at this", + "start": 1916.04, + "duration": 3.75 + }, + { + "text": "point when we get to this line of", + "start": 1918.23, + "duration": 3.57 + }, + { + "text": "JavaScript javascript is looking for the", + "start": 1919.79, + "duration": 4.29 + }, + { + "text": "button but the Dom the body of the page", + "start": 1921.8, + "duration": 4.65 + }, + { + "text": "hasn't finished loading yet the content", + "start": 1924.08, + "duration": 4.56 + }, + { + "text": "of the Dom has not yet loaded and as a", + "start": 1926.45, + "duration": 4.35 + }, + { + "text": "result we're not able to find this", + "start": 1928.64, + "duration": 4.08 + }, + { + "text": "button so how do we solve this problem", + "start": 1930.8, + "duration": 3.6 + }, + { + "text": "how do we get it so we actually are able", + "start": 1932.72, + "duration": 3.87 + }, + { + "text": "to like ask for the button and actually", + "start": 1934.4, + "duration": 3.81 + }, + { + "text": "get the button well it turns out there", + "start": 1936.59, + "duration": 2.97 + }, + { + "text": "are a couple of strategies we could use", + "start": 1938.21, + "duration": 4.02 + }, + { + "text": "one would be take the script tag and go", + "start": 1939.56, + "duration": 4.56 + }, + { + "text": "ahead and just move it to the bottom", + "start": 1942.23, + "duration": 3.84 + }, + { + "text": "section of the body so that after we've", + "start": 1944.12, + "duration": 3.15 + }, + { + "text": "already defined the button that says", + "start": 1946.07, + "duration": 3.0 + }, + { + "text": "count then we have the script tag that", + "start": 1947.27, + "duration": 3.54 + }, + { + "text": "then says alright go ahead and now find", + "start": 1949.07, + "duration": 3.33 + }, + { + "text": "the button and now we'll be able to find", + "start": 1950.81, + "duration": 3.75 + }, + { + "text": "it it turns out another way and perhaps", + "start": 1952.4, + "duration": 5.34 + }, + { + "text": "a more common way is to instead add yet", + "start": 1954.56, + "duration": 5.52 + }, + { + "text": "another event listener and we're gonna", + "start": 1957.74, + "duration": 3.96 + }, + { + "text": "add an event listener not to the button", + "start": 1960.08, + "duration": 4.11 + }, + { + "text": "but to the entire document where", + "start": 1961.7, + "duration": 4.32 + }, + { + "text": "document is a variable built into this", + "start": 1964.19, + "duration": 3.42 + }, + { + "text": "JavaScript that we have access to on the", + "start": 1966.02, + "duration": 3.87 + }, + { + "text": "web page that just refers to this entire", + "start": 1967.61, + "duration": 4.56 + }, + { + "text": "web document where I've used document", + "start": 1969.89, + "duration": 4.44 + }, + { + "text": "query selector already to look through", + "start": 1972.17, + "duration": 3.75 + }, + { + "text": "the whole web document trying to find a", + "start": 1974.33, + "duration": 3.63 + }, + { + "text": "button or trying to find an h1 tag for", + "start": 1975.92, + "duration": 4.77 + }, + { + "text": "example but I can also add an event", + "start": 1977.96, + "duration": 5.64 + }, + { + "text": "listener to the document itself and in", + "start": 1980.69, + "duration": 5.19 + }, + { + "text": "order to do that I can say document dot", + "start": 1983.6, + "duration": 6.66 + }, + { + "text": "add event listener and when I call add", + "start": 1985.88, + "duration": 6.12 + }, + { + "text": "event listener and I can do this on any", + "start": 1990.26, + "duration": 3.69 + }, + { + "text": "HTML element not just the document but I", + "start": 1992.0, + "duration": 3.66 + }, + { + "text": "could run this function on a button or", + "start": 1993.95, + "duration": 3.48 + }, + { + "text": "on an h1 element or any other HTML", + "start": 1995.66, + "duration": 3.72 + }, + { + "text": "element add event listener will", + "start": 1997.43, + "duration": 4.47 + }, + { + "text": "generally take two arguments where the", + "start": 1999.38, + "duration": 5.04 + }, + { + "text": "first is what event I want to listen for", + "start": 2001.9, + "duration": 4.35 + }, + { + "text": "the event could be something like click", + "start": 2004.42, + "duration": 3.69 + }, + { + "text": "when I click on the document it could be", + "start": 2006.25, + "duration": 4.44 + }, + { + "text": "something like when I scroll through a", + "start": 2008.11, + "duration": 4.53 + }, + { + "text": "page for example but with the event I'm", + "start": 2010.69, + "duration": 3.39 + }, + { + "text": "going to listen for is a particularly", + "start": 2012.64, + "duration": 4.17 + }, + { + "text": "special event called Dom content loaded", + "start": 2014.08, + "duration": 6.54 + }, + { + "text": "and the Dom content loaded event is an", + "start": 2016.81, + "duration": 5.01 + }, + { + "text": "event that is going to be", + "start": 2020.62, + "duration": 3.75 + }, + { + "text": "hired or triggered when the Dom the", + "start": 2021.82, + "duration": 4.11 + }, + { + "text": "document object model the structure of", + "start": 2024.37, + "duration": 3.84 + }, + { + "text": "the page is done loading when all of the", + "start": 2025.93, + "duration": 3.48 + }, + { + "text": "elements on the page are done loading", + "start": 2028.21, + "duration": 3.63 + }, + { + "text": "the Dom content has been loaded and then", + "start": 2029.41, + "duration": 4.98 + }, + { + "text": "if I attach an event listener to it you", + "start": 2031.84, + "duration": 4.35 + }, + { + "text": "know run whatever code I want to run", + "start": 2034.39, + "duration": 4.23 + }, + { + "text": "that should only run after the Dom is", + "start": 2036.19, + "duration": 4.59 + }, + { + "text": "fully loaded after all of the content on", + "start": 2038.62, + "duration": 5.04 + }, + { + "text": "the page has then been loaded and the", + "start": 2040.78, + "duration": 5.28 + }, + { + "text": "second argument to an event listener is", + "start": 2043.66, + "duration": 5.73 + }, + { + "text": "what function should run once the event", + "start": 2046.06, + "duration": 4.86 + }, + { + "text": "actually happens when the Dom content", + "start": 2049.39, + "duration": 3.72 + }, + { + "text": "loaded does happen so I could pass in", + "start": 2050.92, + "duration": 4.2 + }, + { + "text": "the name of a function if I had the name", + "start": 2053.11, + "duration": 3.87 + }, + { + "text": "of a function that I wanted to pass in", + "start": 2055.12, + "duration": 4.32 + }, + { + "text": "but alternatively JavaScript allows me", + "start": 2056.98, + "duration": 5.31 + }, + { + "text": "to just directly write a function here", + "start": 2059.44, + "duration": 5.28 + }, + { + "text": "in the argument to add event listener I", + "start": 2062.29, + "duration": 4.92 + }, + { + "text": "can just say function and then a set of", + "start": 2064.72, + "duration": 3.84 + }, + { + "text": "parentheses to mean the function doesn't", + "start": 2067.21, + "duration": 3.69 + }, + { + "text": "take any input and then in curly braces", + "start": 2068.56, + "duration": 4.89 + }, + { + "text": "I can include the body of the function", + "start": 2070.9, + "duration": 6.39 + }, + { + "text": "right here as the second argument to add", + "start": 2073.45, + "duration": 5.4 + }, + { + "text": "event listener and this is a little bit", + "start": 2077.29, + "duration": 2.97 + }, + { + "text": "of tricky syntax to wrap your mind", + "start": 2078.85, + "duration": 2.4 + }, + { + "text": "around if you've never seen it before", + "start": 2080.26, + "duration": 2.85 + }, + { + "text": "but the big-picture way to think of it", + "start": 2081.25, + "duration": 3.9 + }, + { + "text": "is add event listener takes two", + "start": 2083.11, + "duration": 4.44 + }, + { + "text": "arguments one is the event the second is", + "start": 2085.15, + "duration": 4.53 + }, + { + "text": "the function so here first is the event", + "start": 2087.55, + "duration": 4.2 + }, + { + "text": "Dom content loaded and the second", + "start": 2089.68, + "duration": 4.8 + }, + { + "text": "argument is a function and I declare the", + "start": 2091.75, + "duration": 4.11 + }, + { + "text": "function same as before just using", + "start": 2094.48, + "duration": 3.3 + }, + { + "text": "function I haven't given the function a", + "start": 2095.86, + "duration": 4.05 + }, + { + "text": "name because strictly speaking it", + "start": 2097.78, + "duration": 3.18 + }, + { + "text": "doesn't need a name", + "start": 2099.91, + "duration": 2.31 + }, + { + "text": "I'm never going to refer to this", + "start": 2100.96, + "duration": 3.12 + }, + { + "text": "function by name so it is what we might", + "start": 2102.22, + "duration": 3.99 + }, + { + "text": "call an anonymous function a function", + "start": 2104.08, + "duration": 4.71 + }, + { + "text": "that has no name but I'm still passing", + "start": 2106.21, + "duration": 4.32 + }, + { + "text": "it into the add event listener function", + "start": 2108.79, + "duration": 4.47 + }, + { + "text": "as an argument because I want to run the", + "start": 2110.53, + "duration": 4.89 + }, + { + "text": "code inside of the function once the Dom", + "start": 2113.26, + "duration": 4.38 + }, + { + "text": "is done loading and so inside of curly", + "start": 2115.42, + "duration": 4.17 + }, + { + "text": "braces then is the content of that", + "start": 2117.64, + "duration": 3.81 + }, + { + "text": "function the content of what code should", + "start": 2119.59, + "duration": 3.75 + }, + { + "text": "run when the Dom is done loading and", + "start": 2121.45, + "duration": 3.81 + }, + { + "text": "then at the end I again used just this", + "start": 2123.34, + "duration": 3.84 + }, + { + "text": "end parenthesis where that end", + "start": 2125.26, + "duration": 3.54 + }, + { + "text": "parenthesis lines up with this", + "start": 2127.18, + "duration": 4.17 + }, + { + "text": "parenthesis here this is enclosing all", + "start": 2128.8, + "duration": 5.07 + }, + { + "text": "of the arguments to add event listener", + "start": 2131.35, + "duration": 3.96 + }, + { + "text": "where the first one is Dom content", + "start": 2133.87, + "duration": 3.9 + }, + { + "text": "loaded and the second one is this entire", + "start": 2135.31, + "duration": 4.86 + }, + { + "text": "function that might span multiple lines", + "start": 2137.77, + "duration": 4.35 + }, + { + "text": "so you'll see syntax like this quite a", + "start": 2140.17, + "duration": 5.1 + }, + { + "text": "bit in JavaScript but now what I want to", + "start": 2142.12, + "duration": 5.28 + }, + { + "text": "do is adding the event listener to the", + "start": 2145.27, + "duration": 4.32 + }, + { + "text": "button I can go ahead and just for place", + "start": 2147.4, + "duration": 4.77 + }, + { + "text": "and put it here and it turns out that if", + "start": 2149.59, + "duration": 3.15 + }, + { + "text": "I wanted to", + "start": 2152.17, + "duration": 2.37 + }, + { + "text": "instead of saying dot on click equals", + "start": 2152.74, + "duration": 2.97 + }, + { + "text": "count you could", + "start": 2154.54, + "duration": 2.579 + }, + { + "text": "used the same syntax of add", + "start": 2155.71, + "duration": 2.67 + }, + { + "text": "eventlistener I could say at", + "start": 2157.119, + "duration": 5.071 + }, + { + "text": "eventlistener click and then count to", + "start": 2158.38, + "duration": 6.57 + }, + { + "text": "mean when the click event happens go", + "start": 2162.19, + "duration": 4.5 + }, + { + "text": "ahead and run the count function but you", + "start": 2164.95, + "duration": 3.45 + }, + { + "text": "can equivalently shorthand this and just", + "start": 2166.69, + "duration": 4.35 + }, + { + "text": "say dot on click equals count and that", + "start": 2168.4, + "duration": 5.25 + }, + { + "text": "would work just as well so now what", + "start": 2171.04, + "duration": 4.799 + }, + { + "text": "we're saying here is that wait until the", + "start": 2173.65, + "duration": 3.75 + }, + { + "text": "Dom has done loaded wait until all the", + "start": 2175.839, + "duration": 3.811 + }, + { + "text": "content on the page is loaded and then", + "start": 2177.4, + "duration": 4.29 + }, + { + "text": "go ahead and run this function and what", + "start": 2179.65, + "duration": 3.719 + }, + { + "text": "the function is going to do is it's", + "start": 2181.69, + "duration": 3.75 + }, + { + "text": "going to add the event handler to this", + "start": 2183.369, + "duration": 4.171 + }, + { + "text": "button and that'll work because now", + "start": 2185.44, + "duration": 3.929 + }, + { + "text": "we'll be able to find the button because", + "start": 2187.54, + "duration": 3.87 + }, + { + "text": "now all of the content of the Dom has", + "start": 2189.369, + "duration": 5.191 + }, + { + "text": "loaded so now if I go back Refresh", + "start": 2191.41, + "duration": 5.25 + }, + { + "text": "counter dot HTML you'll notice that the", + "start": 2194.56, + "duration": 4.049 + }, + { + "text": "JavaScript error goes away I don't seem", + "start": 2196.66, + "duration": 4.53 + }, + { + "text": "to have that error anymore and now if I", + "start": 2198.609, + "duration": 4.411 + }, + { + "text": "press count were able to see the count", + "start": 2201.19, + "duration": 5.55 + }, + { + "text": "increment just as before as well and so", + "start": 2203.02, + "duration": 5.849 + }, + { + "text": "this then is an improvement upon what", + "start": 2206.74, + "duration": 4.16 + }, + { + "text": "I've had before where now I'm able to", + "start": 2208.869, + "duration": 5.041 + }, + { + "text": "separate out my JavaScript code from all", + "start": 2210.9, + "duration": 5.469 + }, + { + "text": "of the rest of my code as well but much", + "start": 2213.91, + "duration": 4.74 + }, + { + "text": "as in the case of CSS where we were able", + "start": 2216.369, + "duration": 4.021 + }, + { + "text": "to take CSS that was originally located", + "start": 2218.65, + "duration": 3.78 + }, + { + "text": "in the head of our page and move it into", + "start": 2220.39, + "duration": 3.719 + }, + { + "text": "a separate file you can do the same", + "start": 2222.43, + "duration": 3.3 + }, + { + "text": "thing with JavaScript too and this can", + "start": 2224.109, + "duration": 3.031 + }, + { + "text": "be helpful if you have multiple people", + "start": 2225.73, + "duration": 3.03 + }, + { + "text": "working on different files you want one", + "start": 2227.14, + "duration": 3.66 + }, + { + "text": "person working on the HTML and someone", + "start": 2228.76, + "duration": 4.109 + }, + { + "text": "else working on the JavaScript it can be", + "start": 2230.8, + "duration": 4.2 + }, + { + "text": "helpful if you expect that one of these", + "start": 2232.869, + "duration": 3.331 + }, + { + "text": "things is going to change more", + "start": 2235.0, + "duration": 2.52 + }, + { + "text": "frequently than the other so you might", + "start": 2236.2, + "duration": 3.0 + }, + { + "text": "not need to load the other one as often", + "start": 2237.52, + "duration": 3.96 + }, + { + "text": "so there can be value in separating our", + "start": 2239.2, + "duration": 4.59 + }, + { + "text": "HTML code from our JavaScript even more", + "start": 2241.48, + "duration": 4.35 + }, + { + "text": "and by moving our JavaScript into a", + "start": 2243.79, + "duration": 4.23 + }, + { + "text": "separate file and so in order to do that", + "start": 2245.83, + "duration": 5.279 + }, + { + "text": "I can create a new file that I'll just", + "start": 2248.02, + "duration": 5.91 + }, + { + "text": "call counter j/s which will contain all", + "start": 2251.109, + "duration": 6.061 + }, + { + "text": "of the JavaScript for my counter HTML", + "start": 2253.93, + "duration": 6.03 + }, + { + "text": "file so in order to do that what I can", + "start": 2257.17, + "duration": 5.22 + }, + { + "text": "say is let's go ahead and copy all of", + "start": 2259.96, + "duration": 4.83 + }, + { + "text": "this JavaScript code go ahead and cut it", + "start": 2262.39, + "duration": 4.469 + }, + { + "text": "out of this page and I'll paste it into", + "start": 2264.79, + "duration": 3.9 + }, + { + "text": "counter j/s remove some of that", + "start": 2266.859, + "duration": 6.151 + }, + { + "text": "indentation so now I have a file called", + "start": 2268.69, + "duration": 6.63 + }, + { + "text": "counter das that just contains all of", + "start": 2273.01, + "duration": 4.68 + }, + { + "text": "the JavaScript I want to run on my", + "start": 2275.32, + "duration": 6.42 + }, + { + "text": "counter dot HTML page and now rather", + "start": 2277.69, + "duration": 5.82 + }, + { + "text": "than include actual JavaScript in", + "start": 2281.74, + "duration": 4.65 + }, + { + "text": "between these script tags what I can say", + "start": 2283.51, + "duration": 6.599 + }, + { + "text": "is script SRC SRC first", + "start": 2286.39, + "duration": 8.31 + }, + { + "text": "equals a counter Jas for example if I go", + "start": 2290.109, + "duration": 7.47 + }, + { + "text": "ahead and reference counter Jas and use", + "start": 2294.7, + "duration": 5.49 + }, + { + "text": "that JavaScript in the head of the page", + "start": 2297.579, + "duration": 4.47 + }, + { + "text": "here and that then is going to work", + "start": 2300.19, + "duration": 3.72 + }, + { + "text": "exactly in the same way I still am able", + "start": 2302.049, + "duration": 3.78 + }, + { + "text": "to count as high as I'd like I still get", + "start": 2303.91, + "duration": 3.24 + }, + { + "text": "an alert every time the count reaches a", + "start": 2305.829, + "duration": 3.601 + }, + { + "text": "multiple of ten but my HTML is now a", + "start": 2307.15, + "duration": 3.929 + }, + { + "text": "little bit simpler it's just the body", + "start": 2309.43, + "duration": 3.75 + }, + { + "text": "it's just the h1 in the button and then", + "start": 2311.079, + "duration": 5.191 + }, + { + "text": "all of my javascript is now located in a", + "start": 2313.18, + "duration": 5.82 + }, + { + "text": "separate file that allows me to do that", + "start": 2316.27, + "duration": 5.01 + }, + { + "text": "allows me to keep my HTML code and my", + "start": 2319.0, + "duration": 3.599 + }, + { + "text": "JavaScript code separate from each other", + "start": 2321.28, + "duration": 3.24 + }, + { + "text": "and that can be value for valuable for a", + "start": 2322.599, + "duration": 4.081 + }, + { + "text": "couple of reasons among them if I have", + "start": 2324.52, + "duration": 4.68 + }, + { + "text": "common JavaScript code that's in use by", + "start": 2326.68, + "duration": 5.04 + }, + { + "text": "multiple different HTML pages multiple", + "start": 2329.2, + "duration": 4.68 + }, + { + "text": "HTML pages can all include the same", + "start": 2331.72, + "duration": 4.23 + }, + { + "text": "JavaScript source rather than needing to", + "start": 2333.88, + "duration": 2.76 + }, + { + "text": "repeat myself", + "start": 2335.95, + "duration": 2.669 + }, + { + "text": "use the same JavaScript across multiple", + "start": 2336.64, + "duration": 4.02 + }, + { + "text": "different pages I can just use the same", + "start": 2338.619, + "duration": 3.841 + }, + { + "text": "JavaScript across all of them and", + "start": 2340.66, + "duration": 3.78 + }, + { + "text": "that'll be helpful too as we begin to", + "start": 2342.46, + "duration": 3.45 + }, + { + "text": "take a look later at some JavaScript", + "start": 2344.44, + "duration": 3.27 + }, + { + "text": "libraries which are JavaScript written", + "start": 2345.91, + "duration": 4.05 + }, + { + "text": "by other people we can just include", + "start": 2347.71, + "duration": 4.109 + }, + { + "text": "other people's JavaScript in our own", + "start": 2349.96, + "duration": 4.349 + }, + { + "text": "webpages just by adding a script tag at", + "start": 2351.819, + "duration": 4.23 + }, + { + "text": "the top of our page that specifies a", + "start": 2354.309, + "duration": 3.181 + }, + { + "text": "particular source you may have already", + "start": 2356.049, + "duration": 3.601 + }, + { + "text": "interacted with bootstrap that has its", + "start": 2357.49, + "duration": 4.17 + }, + { + "text": "own JavaScript code and you can include", + "start": 2359.65, + "duration": 4.139 + }, + { + "text": "bootstraps JavaScript just by including", + "start": 2361.66, + "duration": 4.86 + }, + { + "text": "a script tag at the top of our HTML page", + "start": 2363.789, + "duration": 5.131 + }, + { + "text": "in order to say go ahead and include all", + "start": 2366.52, + "duration": 6.23 + }, + { + "text": "of that javascript in our page as well", + "start": 2368.92, + "duration": 6.51 + }, + { + "text": "so what else can we do now now that we", + "start": 2372.75, + "duration": 4.539 + }, + { + "text": "have the ability to like get at elements", + "start": 2375.43, + "duration": 3.84 + }, + { + "text": "of the Dom and actually manipulate their", + "start": 2377.289, + "duration": 4.141 + }, + { + "text": "contents well one thing we can do is", + "start": 2379.27, + "duration": 4.47 + }, + { + "text": "begin to make our pages a little bit", + "start": 2381.43, + "duration": 3.929 + }, + { + "text": "more interactive actually respond to", + "start": 2383.74, + "duration": 4.049 + }, + { + "text": "what users are doing on the page whether", + "start": 2385.359, + "duration": 4.68 + }, + { + "text": "the user is typing something in or maybe", + "start": 2387.789, + "duration": 4.381 + }, + { + "text": "filling out a form for example so let's", + "start": 2390.039, + "duration": 3.721 + }, + { + "text": "go ahead and try an example of that", + "start": 2392.17, + "duration": 3.09 + }, + { + "text": "where the user might be filling out a", + "start": 2393.76, + "duration": 3.51 + }, + { + "text": "form and we would like for our code to", + "start": 2395.26, + "duration": 4.109 + }, + { + "text": "somehow respond to what it is that they", + "start": 2397.27, + "duration": 4.11 + }, + { + "text": "type I'll go ahead and go back into", + "start": 2399.369, + "duration": 6.42 + }, + { + "text": "hello dot HTML and now inside of the", + "start": 2401.38, + "duration": 6.479 + }, + { + "text": "body of the page I've said hello at the", + "start": 2405.789, + "duration": 3.99 + }, + { + "text": "top I'm here instead of a button I'm", + "start": 2407.859, + "duration": 5.46 + }, + { + "text": "going to have a form this HTML form will", + "start": 2409.779, + "duration": 4.83 + }, + { + "text": "look like the HTML forms we've seen", + "start": 2413.319, + "duration": 3.871 + }, + { + "text": "before a have an input field that'll add", + "start": 2414.609, + "duration": 4.531 + }, + { + "text": "the auto focus attribute to to mean like", + "start": 2417.19, + "duration": 3.24 + }, + { + "text": "automatically focus this input field", + "start": 2419.14, + "duration": 3.179 + }, + { + "text": "when I open the page because I might", + "start": 2420.43, + "duration": 2.189 + }, + { + "text": "want", + "start": 2422.319, + "duration": 2.911 + }, + { + "text": "user to start typing right away I'm", + "start": 2422.619, + "duration": 4.67 + }, + { + "text": "gonna give this input field an ID of", + "start": 2425.23, + "duration": 5.789 + }, + { + "text": "name for example and then a placeholder", + "start": 2427.289, + "duration": 9.641 + }, + { + "text": "of name capital n whose type is text so", + "start": 2431.019, + "duration": 7.201 + }, + { + "text": "what have I done here I've created an", + "start": 2436.93, + "duration": 2.76 + }, + { + "text": "input field where the user can type in", + "start": 2438.22, + "duration": 3.51 + }, + { + "text": "some text the placeholder the thing the", + "start": 2439.69, + "duration": 4.02 + }, + { + "text": "user see is filled into that input field", + "start": 2441.73, + "duration": 4.26 + }, + { + "text": "originally will just be capital and name", + "start": 2443.71, + "duration": 3.69 + }, + { + "text": "telling them they should type their name", + "start": 2445.99, + "duration": 3.869 + }, + { + "text": "in here and I've given this input field", + "start": 2447.4, + "duration": 6.09 + }, + { + "text": "an ID some unique identifier such that I", + "start": 2449.859, + "duration": 6.361 + }, + { + "text": "later on can reference and find this", + "start": 2453.49, + "duration": 5.67 + }, + { + "text": "particular input field and then I have", + "start": 2456.22, + "duration": 5.97 + }, + { + "text": "input type equals submit some way for me", + "start": 2459.16, + "duration": 7.439 + }, + { + "text": "to now submit this form as well and so", + "start": 2462.19, + "duration": 7.579 + }, + { + "text": "if I load this page load hello dot HTML", + "start": 2466.599, + "duration": 6.27 + }, + { + "text": "here's what I see hello a field where I", + "start": 2469.769, + "duration": 4.75 + }, + { + "text": "can type in my name the placeholder name", + "start": 2472.869, + "duration": 3.301 + }, + { + "text": "shows up there for me and then a button", + "start": 2474.519, + "duration": 5.52 + }, + { + "text": "where I can submit this form and now", + "start": 2476.17, + "duration": 5.55 + }, + { + "text": "what I'd like to do inside of my", + "start": 2480.039, + "duration": 3.75 + }, + { + "text": "JavaScript is instead of this hello", + "start": 2481.72, + "duration": 3.779 + }, + { + "text": "function what I'm going to do is I'm", + "start": 2483.789, + "duration": 4.23 + }, + { + "text": "going to first run some JavaScript when", + "start": 2485.499, + "duration": 4.171 + }, + { + "text": "the Dom is done loading and so I'll use", + "start": 2488.019, + "duration": 2.941 + }, + { + "text": "that same line from before you're gonna", + "start": 2489.67, + "duration": 2.97 + }, + { + "text": "see it quite a bit we're gonna say", + "start": 2490.96, + "duration": 4.529 + }, + { + "text": "document add event listener Dom content", + "start": 2492.64, + "duration": 5.669 + }, + { + "text": "loaded and then this function to mean go", + "start": 2495.489, + "duration": 4.86 + }, + { + "text": "ahead and run this code when the Dom is", + "start": 2498.309, + "duration": 4.171 + }, + { + "text": "done loaded and the code I'd like to run", + "start": 2500.349, + "duration": 6.69 + }, + { + "text": "is to say when I submit the form I want", + "start": 2502.48, + "duration": 6.089 + }, + { + "text": "something to happen when I submit the", + "start": 2507.039, + "duration": 3.06 + }, + { + "text": "form maybe I want to display an alert", + "start": 2508.569, + "duration": 3.601 + }, + { + "text": "that if I type in Brian it'll say hello", + "start": 2510.099, + "duration": 3.541 + }, + { + "text": "Brian or if I typed in David it'll say", + "start": 2512.17, + "duration": 3.72 + }, + { + "text": "hello David for example so how many I do", + "start": 2513.64, + "duration": 4.74 + }, + { + "text": "that well how do I get the form that's", + "start": 2515.89, + "duration": 3.99 + }, + { + "text": "the first question anytime you want to", + "start": 2518.38, + "duration": 3.659 + }, + { + "text": "get at an element one particular element", + "start": 2519.88, + "duration": 4.619 + }, + { + "text": "on an HTML page usually what we're going", + "start": 2522.039, + "duration": 5.641 + }, + { + "text": "to do is document dot query selector to", + "start": 2524.499, + "duration": 5.55 + }, + { + "text": "say get me the element that is a form", + "start": 2527.68, + "duration": 3.99 + }, + { + "text": "and there's only one form on the page so", + "start": 2530.049, + "duration": 3.06 + }, + { + "text": "I don't have to worry about ambiguity", + "start": 2531.67, + "duration": 3.56 + }, + { + "text": "I'm just saying get me that form and", + "start": 2533.109, + "duration": 6.24 + }, + { + "text": "then I can say dot on submit when you", + "start": 2535.23, + "duration": 6.849 + }, + { + "text": "submit the form what code should run and", + "start": 2539.349, + "duration": 4.561 + }, + { + "text": "if I had a name of a function like a", + "start": 2542.079, + "duration": 4.051 + }, + { + "text": "function f I could just say like run", + "start": 2543.91, + "duration": 4.369 + }, + { + "text": "function f when the form is submitted", + "start": 2546.13, + "duration": 5.28 + }, + { + "text": "but alternatively just as before instead", + "start": 2548.279, + "duration": 4.631 + }, + { + "text": "of providing the name of a function I", + "start": 2551.41, + "duration": 3.57 + }, + { + "text": "can also just provide the function", + "start": 2552.91, + "duration": 2.84 + }, + { + "text": "itself", + "start": 2554.98, + "duration": 4.01 + }, + { + "text": "I can say function and then in between", + "start": 2555.75, + "duration": 6.39 + }, + { + "text": "these curly braces I can specify exactly", + "start": 2558.99, + "duration": 5.82 + }, + { + "text": "what code should run when the form is", + "start": 2562.14, + "duration": 4.41 + }, + { + "text": "submitted by providing this anonymous", + "start": 2564.81, + "duration": 4.08 + }, + { + "text": "function instead using this anonymous", + "start": 2566.55, + "duration": 5.28 + }, + { + "text": "function as the value of the on submit", + "start": 2568.89, + "duration": 5.94 + }, + { + "text": "property of this form and so now what", + "start": 2571.83, + "duration": 5.1 + }, + { + "text": "I'd like to do is somehow get access to", + "start": 2574.83, + "duration": 4.35 + }, + { + "text": "whatever the user typed into the input", + "start": 2576.93, + "duration": 4.29 + }, + { + "text": "field whatever the user's name happens", + "start": 2579.18, + "duration": 4.14 + }, + { + "text": "to be and so I could get the input field", + "start": 2581.22, + "duration": 5.49 + }, + { + "text": "by a document dot query selector input", + "start": 2583.32, + "duration": 5.88 + }, + { + "text": "and that would work this time but we'll", + "start": 2586.71, + "duration": 3.81 + }, + { + "text": "want to start to be a little bit careful", + "start": 2589.2, + "duration": 2.97 + }, + { + "text": "because on this page there are multiple", + "start": 2590.52, + "duration": 3.18 + }, + { + "text": "different input elements as an input", + "start": 2592.17, + "duration": 3.54 + }, + { + "text": "element here for typing in the name and", + "start": 2593.7, + "duration": 5.16 + }, + { + "text": "a second input element here for telling", + "start": 2595.71, + "duration": 4.86 + }, + { + "text": "me giving me a button where I can submit", + "start": 2598.86, + "duration": 4.08 + }, + { + "text": "this particular HTML form and so what I", + "start": 2600.57, + "duration": 4.5 + }, + { + "text": "probably want to do is be a little bit", + "start": 2602.94, + "duration": 4.44 + }, + { + "text": "more specific and it turns out that", + "start": 2605.07, + "duration": 4.41 + }, + { + "text": "inside of query selector I can use all", + "start": 2607.38, + "duration": 4.53 + }, + { + "text": "of the standard ways in CSS that we", + "start": 2609.48, + "duration": 5.04 + }, + { + "text": "could select for a particular element so", + "start": 2611.91, + "duration": 5.01 + }, + { + "text": "in CSS if you'll recall we had the", + "start": 2614.52, + "duration": 4.8 + }, + { + "text": "ability to run CSS and just say style", + "start": 2616.92, + "duration": 4.95 + }, + { + "text": "all the h1 or we could say style all the", + "start": 2619.32, + "duration": 4.29 + }, + { + "text": "things with this particular ID or with", + "start": 2621.87, + "duration": 3.93 + }, + { + "text": "this particular class and document our", + "start": 2623.61, + "duration": 4.2 + }, + { + "text": "query selector works the same way that I", + "start": 2625.8, + "duration": 4.41 + }, + { + "text": "can say document query selector and pass", + "start": 2627.81, + "duration": 5.31 + }, + { + "text": "in a tag to say like get me the h1", + "start": 2630.21, + "duration": 4.8 + }, + { + "text": "element or get me the button or get me", + "start": 2633.12, + "duration": 3.99 + }, + { + "text": "the form but if there are multiple h1", + "start": 2635.01, + "duration": 3.54 + }, + { + "text": "elements are multiple buttons and", + "start": 2637.11, + "duration": 3.21 + }, + { + "text": "multiple forms I can be more specific", + "start": 2638.55, + "duration": 2.28 + }, + { + "text": "than that", + "start": 2640.32, + "duration": 3.9 + }, + { + "text": "if for example an element has an ID in", + "start": 2640.83, + "duration": 5.43 + }, + { + "text": "which case I can say document query", + "start": 2644.22, + "duration": 4.56 + }, + { + "text": "selector and then in quotation marks the", + "start": 2646.26, + "duration": 5.34 + }, + { + "text": "hash mark and then the name of the ID to", + "start": 2648.78, + "duration": 4.35 + }, + { + "text": "say get me the element with that", + "start": 2651.6, + "duration": 3.75 + }, + { + "text": "particular ID again using the exact same", + "start": 2653.13, + "duration": 5.4 + }, + { + "text": "syntax that CSS uses if I want to apply", + "start": 2655.35, + "duration": 5.64 + }, + { + "text": "a particular set of styles to only one", + "start": 2658.53, + "duration": 5.64 + }, + { + "text": "element that only has one ID likewise", + "start": 2660.99, + "duration": 5.49 + }, + { + "text": "two I can say document query selector", + "start": 2664.17, + "duration": 4.92 + }, + { + "text": "and then use dot followed by the name of", + "start": 2666.48, + "duration": 4.41 + }, + { + "text": "a class if there's a particular", + "start": 2669.09, + "duration": 3.93 + }, + { + "text": "particular class of elements and I want", + "start": 2670.89, + "duration": 4.5 + }, + { + "text": "to just get one of those and to say get", + "start": 2673.02, + "duration": 4.53 + }, + { + "text": "me an element that has this particular", + "start": 2675.39, + "duration": 4.5 + }, + { + "text": "class in order to manipulate it as well", + "start": 2677.55, + "duration": 4.23 + }, + { + "text": "so the same types of syntax that we", + "start": 2679.89, + "duration": 4.23 + }, + { + "text": "could use in CSS for trying to reference", + "start": 2681.78, + "duration": 5.22 + }, + { + "text": "and get at a particular HTML element we", + "start": 2684.12, + "duration": 4.86 + }, + { + "text": "can do the same thing here with document", + "start": 2687.0, + "duration": 2.64 + }, + { + "text": "query so", + "start": 2688.98, + "duration": 3.72 + }, + { + "text": "to go ahead and try and get a particular", + "start": 2689.64, + "duration": 5.07 + }, + { + "text": "element based on its tag name based on", + "start": 2692.7, + "duration": 4.5 + }, + { + "text": "this ID or based on its class and it was", + "start": 2694.71, + "duration": 4.44 + }, + { + "text": "for that reason that inside of the HTML", + "start": 2697.2, + "duration": 5.7 + }, + { + "text": "page for my input I gave the input an", + "start": 2699.15, + "duration": 6.719 + }, + { + "text": "idea of name I wanted some way to be", + "start": 2702.9, + "duration": 5.219 + }, + { + "text": "able to uniquely reference it and I can", + "start": 2705.869, + "duration": 4.531 + }, + { + "text": "uniquely reference it not by input but", + "start": 2708.119, + "duration": 5.341 + }, + { + "text": "by pound name where I can say get me the", + "start": 2710.4, + "duration": 6.24 + }, + { + "text": "element that has an ID of name and that", + "start": 2713.46, + "duration": 4.409 + }, + { + "text": "is the element that I would like to", + "start": 2716.64, + "duration": 3.619 + }, + { + "text": "extract inside of my JavaScript code", + "start": 2717.869, + "duration": 5.041 + }, + { + "text": "once I have that HTML element what I", + "start": 2720.259, + "duration": 4.121 + }, + { + "text": "want is like what the user actually", + "start": 2722.91, + "duration": 4.109 + }, + { + "text": "typed into that input field and it turns", + "start": 2724.38, + "duration": 4.05 + }, + { + "text": "out that if you have an input field in", + "start": 2727.019, + "duration": 3.72 + }, + { + "text": "HTML I can get access to what the user", + "start": 2728.43, + "duration": 5.129 + }, + { + "text": "typed in by accessing its value property", + "start": 2730.739, + "duration": 4.921 + }, + { + "text": "value is a property that fur that refers", + "start": 2733.559, + "duration": 4.351 + }, + { + "text": "to what it is the user actually typed in", + "start": 2735.66, + "duration": 6.389 + }, + { + "text": "so I can say dot value and I'm going to", + "start": 2737.91, + "duration": 5.669 + }, + { + "text": "go ahead and save that inside of a", + "start": 2742.049, + "duration": 3.121 + }, + { + "text": "variable so I could say something like", + "start": 2743.579, + "duration": 4.2 + }, + { + "text": "let name equal whatever the user typed", + "start": 2745.17, + "duration": 4.8 + }, + { + "text": "in but if I'm not going to reassign name", + "start": 2747.779, + "duration": 3.691 + }, + { + "text": "to something else inside of this", + "start": 2749.97, + "duration": 3.149 + }, + { + "text": "function inside of this function I'm", + "start": 2751.47, + "duration": 3.149 + }, + { + "text": "really going to get the name once and", + "start": 2753.119, + "duration": 2.94 + }, + { + "text": "I'm not gonna change it inside of the", + "start": 2754.619, + "duration": 3.9 + }, + { + "text": "function so I can use a constable", + "start": 2756.059, + "duration": 4.171 + }, + { + "text": "instead that would be better designed to", + "start": 2758.519, + "duration": 3.51 + }, + { + "text": "say I have a constant variable called", + "start": 2760.23, + "duration": 3.9 + }, + { + "text": "name which is equal to document query", + "start": 2762.029, + "duration": 4.171 + }, + { + "text": "selector get me the element whose ideas", + "start": 2764.13, + "duration": 5.879 + }, + { + "text": "name and get access to its value and now", + "start": 2766.2, + "duration": 5.849 + }, + { + "text": "I can display an alert I can alert", + "start": 2770.009, + "duration": 5.911 + }, + { + "text": "something like in backticks hello comma", + "start": 2772.049, + "duration": 6.48 + }, + { + "text": "and then using the dollar sign curly", + "start": 2775.92, + "duration": 4.5 + }, + { + "text": "brace syntax I can say plug in the name", + "start": 2778.529, + "duration": 4.851 + }, + { + "text": "there followed by an exclamation point", + "start": 2780.42, + "duration": 5.49 + }, + { + "text": "so I've extracted the name from the form", + "start": 2783.38, + "duration": 4.389 + }, + { + "text": "get me the input field where they type", + "start": 2785.91, + "duration": 3.839 + }, + { + "text": "to the name get access to its value and", + "start": 2787.769, + "duration": 4.32 + }, + { + "text": "then I'm displaying an alert that is", + "start": 2789.749, + "duration": 5.401 + }, + { + "text": "going to say hello to that person for", + "start": 2792.089, + "duration": 7.71 + }, + { + "text": "example and so now for refresh the page", + "start": 2795.15, + "duration": 8.04 + }, + { + "text": "I type in my name I press submit I get", + "start": 2799.799, + "duration": 4.891 + }, + { + "text": "an alert that says hello Brian", + "start": 2803.19, + "duration": 4.859 + }, + { + "text": "press ok I can try it again I can type", + "start": 2804.69, + "duration": 5.099 + }, + { + "text": "in something like David it press submit", + "start": 2808.049, + "duration": 4.55 + }, + { + "text": "and now the page says hello David", + "start": 2809.789, + "duration": 5.101 + }, + { + "text": "so here again we've been able to combine", + "start": 2812.599, + "duration": 4.99 + }, + { + "text": "event listeners and functions and query", + "start": 2814.89, + "duration": 5.31 + }, + { + "text": "selector to be able to both read", + "start": 2817.589, + "duration": 4.351 + }, + { + "text": "information from the page in order to", + "start": 2820.2, + "duration": 2.76 + }, + { + "text": "say get me", + "start": 2821.94, + "duration": 3.36 + }, + { + "text": "this particular HTML element find me an", + "start": 2822.96, + "duration": 4.71 + }, + { + "text": "HTML element and access like what the", + "start": 2825.3, + "duration": 4.02 + }, + { + "text": "user typed into it the dot value", + "start": 2827.67, + "duration": 3.39 + }, + { + "text": "property that gets me what the user", + "start": 2829.32, + "duration": 3.69 + }, + { + "text": "typed into an input field and we've been", + "start": 2831.06, + "duration": 3.57 + }, + { + "text": "able to combine that with event", + "start": 2833.01, + "duration": 3.09 + }, + { + "text": "listeners and alerts that are able to", + "start": 2834.63, + "duration": 4.14 + }, + { + "text": "actually respond dynamically to when a", + "start": 2836.1, + "duration": 4.5 + }, + { + "text": "user submits the form or when the entire", + "start": 2838.77, + "duration": 3.99 + }, + { + "text": "content of the page is done loading in", + "start": 2840.6, + "duration": 3.66 + }, + { + "text": "order to produce some interesting", + "start": 2842.76, + "duration": 4.8 + }, + { + "text": "effects as well but it turns out we can", + "start": 2844.26, + "duration": 6.03 + }, + { + "text": "do more than just change like the HTML", + "start": 2847.56, + "duration": 4.98 + }, + { + "text": "that is contained within an element we", + "start": 2850.29, + "duration": 4.74 + }, + { + "text": "can also change CSS as well change the", + "start": 2852.54, + "duration": 4.62 + }, + { + "text": "style properties of a particular element", + "start": 2855.03, + "duration": 4.62 + }, + { + "text": "as well so let's go ahead and see an", + "start": 2857.16, + "duration": 4.89 + }, + { + "text": "example of that I'll go ahead and create", + "start": 2859.65, + "duration": 5.25 + }, + { + "text": "a new file then I'll call colors HTML", + "start": 2862.05, + "duration": 4.92 + }, + { + "text": "and inside of colors I'll include the", + "start": 2864.9, + "duration": 5.88 + }, + { + "text": "same standard HTML boilerplate code that", + "start": 2866.97, + "duration": 5.34 + }, + { + "text": "we often start with a head section with", + "start": 2870.78, + "duration": 4.71 + }, + { + "text": "a title and a body section and inside of", + "start": 2872.31, + "duration": 5.4 + }, + { + "text": "the body of this page I'm going to", + "start": 2875.49, + "duration": 5.58 + }, + { + "text": "display a heading that just says hello", + "start": 2877.71, + "duration": 5.61 + }, + { + "text": "for example and maybe I'll give it an ID", + "start": 2881.07, + "duration": 4.38 + }, + { + "text": "just so I can reference it by name maybe", + "start": 2883.32, + "duration": 5.34 + }, + { + "text": "it has an ID of hello and then I'll have", + "start": 2885.45, + "duration": 6.15 + }, + { + "text": "three buttons I'll have a button called", + "start": 2888.66, + "duration": 6.54 + }, + { + "text": "read a button called blue and then a", + "start": 2891.6, + "duration": 7.11 + }, + { + "text": "button called green for example where", + "start": 2895.2, + "duration": 7.14 + }, + { + "text": "now if I open up colors dot HTML here's", + "start": 2898.71, + "duration": 5.76 + }, + { + "text": "what I see I see a big heading that says", + "start": 2902.34, + "duration": 4.2 + }, + { + "text": "hello and then I see three buttons red", + "start": 2904.47, + "duration": 3.48 + }, + { + "text": "blue and green but of course right now", + "start": 2906.54, + "duration": 3.9 + }, + { + "text": "these buttons don't actually do anything", + "start": 2907.95, + "duration": 4.5 + }, + { + "text": "how do I get the buttons to do something", + "start": 2910.44, + "duration": 4.02 + }, + { + "text": "well that's where JavaScript's going to", + "start": 2912.45, + "duration": 3.99 + }, + { + "text": "come in I'll add a script tag to the top", + "start": 2914.46, + "duration": 4.35 + }, + { + "text": "of my page and I only want to run this", + "start": 2916.44, + "duration": 4.05 + }, + { + "text": "JavaScript when the Dom is done loading", + "start": 2918.81, + "duration": 3.87 + }, + { + "text": "so again we'll use the same syntax as", + "start": 2920.49, + "duration": 5.42 + }, + { + "text": "before document dot add eventlistener", + "start": 2922.68, + "duration": 7.14 + }, + { + "text": "Dom content loaded and then run this", + "start": 2925.91, + "duration": 6.1 + }, + { + "text": "function to say everything in between", + "start": 2929.82, + "duration": 4.44 + }, + { + "text": "these curly braces this is all the code", + "start": 2932.01, + "duration": 4.05 + }, + { + "text": "that should run once the page is done", + "start": 2934.26, + "duration": 3.81 + }, + { + "text": "loading and what I'd really like to do", + "start": 2936.06, + "duration": 4.2 + }, + { + "text": "is get at these three buttons and say", + "start": 2938.07, + "duration": 3.48 + }, + { + "text": "when you click on each one of them do", + "start": 2940.26, + "duration": 2.55 + }, + { + "text": "something different like change the", + "start": 2941.55, + "duration": 3.93 + }, + { + "text": "color of a particular HTML element and", + "start": 2942.81, + "duration": 4.29 + }, + { + "text": "in order to do that I need some way of", + "start": 2945.48, + "duration": 3.63 + }, + { + "text": "uniquely referencing these buttons so to", + "start": 2947.1, + "duration": 3.18 + }, + { + "text": "do that I'm going to give them all IDs", + "start": 2949.11, + "duration": 3.78 + }, + { + "text": "this button will have an ID of red this", + "start": 2950.28, + "duration": 4.59 + }, + { + "text": "button will have an ID of blue this", + "start": 2952.89, + "duration": 3.69 + }, + { + "text": "button will have an ID of green", + "start": 2954.87, + "duration": 3.45 + }, + { + "text": "unique names I can give to the buttons", + "start": 2956.58, + "duration": 4.17 + }, + { + "text": "in HTML such that in JavaScript", + "start": 2958.32, + "duration": 5.97 + }, + { + "text": "I'm later able to reference them so what", + "start": 2960.75, + "duration": 5.64 + }, + { + "text": "I what do I include now here inside of", + "start": 2964.29, + "duration": 3.18 + }, + { + "text": "my JavaScript code", + "start": 2966.39, + "duration": 4.5 + }, + { + "text": "well let me say document dot query", + "start": 2967.47, + "duration": 8.13 + }, + { + "text": "selector hash read to say get me the", + "start": 2970.89, + "duration": 8.4 + }, + { + "text": "element whose ID is read and when you're", + "start": 2975.6, + "duration": 6.27 + }, + { + "text": "clicked on on click go ahead and run", + "start": 2979.29, + "duration": 4.14 + }, + { + "text": "this function", + "start": 2981.87, + "duration": 3.63 + }, + { + "text": "what should the function do well I want", + "start": 2983.43, + "duration": 4.59 + }, + { + "text": "to take this h1 element and change its", + "start": 2985.5, + "duration": 5.04 + }, + { + "text": "color to red I want to change the font", + "start": 2988.02, + "duration": 4.62 + }, + { + "text": "color to red and I'll leave a comment to", + "start": 2990.54, + "duration": 3.9 + }, + { + "text": "myself in JavaScript the way you can", + "start": 2992.64, + "duration": 3.21 + }, + { + "text": "leave a comment just a document what", + "start": 2994.44, + "duration": 3.24 + }, + { + "text": "you're doing is using these two slashes", + "start": 2995.85, + "duration": 3.78 + }, + { + "text": "the two slashes indicate everything", + "start": 2997.68, + "duration": 3.66 + }, + { + "text": "after that on the page is going to be a", + "start": 2999.63, + "duration": 3.78 + }, + { + "text": "comment browser will ignore it but it", + "start": 3001.34, + "duration": 3.78 + }, + { + "text": "can be useful to use a programmer and to", + "start": 3003.41, + "duration": 3.18 + }, + { + "text": "someone who's reading your code to be", + "start": 3005.12, + "duration": 3.03 + }, + { + "text": "able to see what it is that you're", + "start": 3006.59, + "duration": 4.29 + }, + { + "text": "describing here on the page and now what", + "start": 3008.15, + "duration": 5.25 + }, + { + "text": "I'd like to do is document query", + "start": 3010.88, + "duration": 6.39 + }, + { + "text": "selector hello get me the HTML element", + "start": 3013.4, + "duration": 6.39 + }, + { + "text": "whose ID is hello and go ahead and", + "start": 3017.27, + "duration": 6.24 + }, + { + "text": "modify its style property and now inside", + "start": 3019.79, + "duration": 6.27 + }, + { + "text": "of this style object I can modify any of", + "start": 3023.51, + "duration": 4.68 + }, + { + "text": "the CSS style properties one of them for", + "start": 3026.06, + "duration": 5.01 + }, + { + "text": "example is something like color so I can", + "start": 3028.19, + "duration": 5.34 + }, + { + "text": "update the color property and set it", + "start": 3031.07, + "duration": 6.87 + }, + { + "text": "equal to red so here now I'm saying when", + "start": 3033.53, + "duration": 6.9 + }, + { + "text": "you click on the red button go ahead and", + "start": 3037.94, + "duration": 4.65 + }, + { + "text": "run this function and what the function", + "start": 3040.43, + "duration": 4.59 + }, + { + "text": "should do is find the hello element", + "start": 3042.59, + "duration": 5.1 + }, + { + "text": "update it style what part of the style", + "start": 3045.02, + "duration": 3.84 + }, + { + "text": "update its color", + "start": 3047.69, + "duration": 3.54 + }, + { + "text": "what should we update it to we should", + "start": 3048.86, + "duration": 5.16 + }, + { + "text": "update it to red and I'm gonna do the", + "start": 3051.23, + "duration": 4.29 + }, + { + "text": "same thing for the other two buttons as", + "start": 3054.02, + "duration": 3.06 + }, + { + "text": "well and it's pretty similar codes I'm", + "start": 3055.52, + "duration": 4.26 + }, + { + "text": "just going to copy paste copy paste here", + "start": 3057.08, + "duration": 3.99 + }, + { + "text": "I'm gonna have one for changing the", + "start": 3059.78, + "duration": 3.27 + }, + { + "text": "color to blue when I click the blue", + "start": 3061.07, + "duration": 3.51 + }, + { + "text": "button you should change the color to", + "start": 3063.05, + "duration": 4.05 + }, + { + "text": "blue and then we'll do it one more time", + "start": 3064.58, + "duration": 5.34 + }, + { + "text": "change the font color to green when you", + "start": 3067.1, + "duration": 4.26 + }, + { + "text": "click on the green button you should", + "start": 3069.92, + "duration": 5.67 + }, + { + "text": "change the color to green so now when i", + "start": 3071.36, + "duration": 6.75 + }, + { + "text": "refresh the colors wml right now hello", + "start": 3075.59, + "duration": 4.11 + }, + { + "text": "by default it's just in black standard", + "start": 3078.11, + "duration": 4.68 + }, + { + "text": "font color for HTML I click red hello", + "start": 3079.7, + "duration": 4.74 + }, + { + "text": "changes to red I click blue it changes", + "start": 3082.79, + "duration": 3.96 + }, + { + "text": "to blue I click green it changes to", + "start": 3084.44, + "duration": 3.78 + }, + { + "text": "green so depending on what button I", + "start": 3086.75, + "duration": 3.72 + }, + { + "text": "click that triggers some event listener", + "start": 3088.22, + "duration": 4.5 + }, + { + "text": "that's going to then say when the button", + "start": 3090.47, + "duration": 4.05 + }, + { + "text": "is clicked run this function and what", + "start": 3092.72, + "duration": 4.2 + }, + { + "text": "the function does is it grabs this h1", + "start": 3094.52, + "duration": 4.37 + }, + { + "text": "element the element whose ID is hello", + "start": 3096.92, + "duration": 4.679 + }, + { + "text": "modifies it style updates its color", + "start": 3098.89, + "duration": 4.84 + }, + { + "text": "property to be something like red or", + "start": 3101.599, + "duration": 4.801 + }, + { + "text": "blue or green and that's showing that we", + "start": 3103.73, + "duration": 3.57 + }, + { + "text": "can modify style", + "start": 3106.4, + "duration": 2.82 + }, + { + "text": "in addition and just modifying the", + "start": 3107.3, + "duration": 5.519 + }, + { + "text": "content of the page itself but it turns", + "start": 3109.22, + "duration": 5.07 + }, + { + "text": "out that as you looked at me writing", + "start": 3112.819, + "duration": 2.79 + }, + { + "text": "that code something should have struck", + "start": 3114.29, + "duration": 3.69 + }, + { + "text": "you is probably not optimal design then", + "start": 3115.609, + "duration": 4.021 + }, + { + "text": "in general any time you find yourself", + "start": 3117.98, + "duration": 3.3 + }, + { + "text": "writing the same code again and again", + "start": 3119.63, + "duration": 3.209 + }, + { + "text": "and again especially if your copy", + "start": 3121.28, + "duration": 3.45 + }, + { + "text": "pasting that that is a generally a bad", + "start": 3122.839, + "duration": 3.931 + }, + { + "text": "sign usually a sign that there is some", + "start": 3124.73, + "duration": 5.4 + }, + { + "text": "better way of trying to modify of trying", + "start": 3126.77, + "duration": 4.98 + }, + { + "text": "to implement the behavior that I'm", + "start": 3130.13, + "duration": 3.33 + }, + { + "text": "trying to create and it turns out that", + "start": 3131.75, + "duration": 2.91 + }, + { + "text": "there is and there are a number of ways", + "start": 3133.46, + "duration": 4.109 + }, + { + "text": "that you could do this one way here is", + "start": 3134.66, + "duration": 4.439 + }, + { + "text": "that I might like to consolidate these", + "start": 3137.569, + "duration": 4.141 + }, + { + "text": "three event listeners into just like a", + "start": 3139.099, + "duration": 4.831 + }, + { + "text": "single function that is going to handle", + "start": 3141.71, + "duration": 4.77 + }, + { + "text": "changing the color to whatever the", + "start": 3143.93, + "duration": 4.35 + }, + { + "text": "button says the color should be changed", + "start": 3146.48, + "duration": 4.74 + }, + { + "text": "to but one problem here is that if I", + "start": 3148.28, + "duration": 4.74 + }, + { + "text": "just attach the same event listener to", + "start": 3151.22, + "duration": 4.32 + }, + { + "text": "all three of the buttons it's not going", + "start": 3153.02, + "duration": 4.98 + }, + { + "text": "to be clear to me when I click on the", + "start": 3155.54, + "duration": 3.87 + }, + { + "text": "button how does the button know what", + "start": 3158.0, + "duration": 4.02 + }, + { + "text": "color we should change the text to and", + "start": 3159.41, + "duration": 5.429 + }, + { + "text": "so to that effect we can add some", + "start": 3162.02, + "duration": 5.099 + }, + { + "text": "additional special attributes to a", + "start": 3164.839, + "duration": 4.5 + }, + { + "text": "particular HTML element that are called", + "start": 3167.119, + "duration": 5.131 + }, + { + "text": "data attributes where a data attribute", + "start": 3169.339, + "duration": 5.911 + }, + { + "text": "is my way of saying that I would like to", + "start": 3172.25, + "duration": 5.339 + }, + { + "text": "associate some data with this particular", + "start": 3175.25, + "duration": 4.98 + }, + { + "text": "h2 what HTML element we're here I can", + "start": 3177.589, + "duration": 7.651 + }, + { + "text": "say data - color equals red data - color", + "start": 3180.23, + "duration": 8.67 + }, + { + "text": "equals blue data - color equals green", + "start": 3185.24, + "duration": 5.849 + }, + { + "text": "data attributes always start with data", + "start": 3188.9, + "duration": 4.02 + }, + { + "text": "followed by a dash and then I can", + "start": 3191.089, + "duration": 3.75 + }, + { + "text": "specify really any name that I want for", + "start": 3192.92, + "duration": 3.39 + }, + { + "text": "some information that I would like to", + "start": 3194.839, + "duration": 4.26 + }, + { + "text": "store about the HTML element and here", + "start": 3196.31, + "duration": 4.89 + }, + { + "text": "the information I want to store is I", + "start": 3199.099, + "duration": 4.441 + }, + { + "text": "want to store data about what color you", + "start": 3201.2, + "duration": 4.23 + }, + { + "text": "should change the text to when the", + "start": 3203.54, + "duration": 3.45 + }, + { + "text": "button is clicked on and so what we're", + "start": 3205.43, + "duration": 3.51 + }, + { + "text": "gonna have the ability to do now is the", + "start": 3206.99, + "duration": 3.9 + }, + { + "text": "ability to say that if I have access to", + "start": 3208.94, + "duration": 4.77 + }, + { + "text": "this element this button I can access", + "start": 3210.89, + "duration": 6.09 + }, + { + "text": "its data color property to know whether", + "start": 3213.71, + "duration": 5.28 + }, + { + "text": "we should change the text to red or blue", + "start": 3216.98, + "duration": 4.32 + }, + { + "text": "or green by adding these data attributes", + "start": 3218.99, + "duration": 4.39 + }, + { + "text": "to these HTML elements", + "start": 3221.3, + "duration": 4.33 + }, + { + "text": "and so now what I want is some way of", + "start": 3223.38, + "duration": 4.439 + }, + { + "text": "getting all of these buttons now", + "start": 3225.63, + "duration": 5.31 + }, + { + "text": "document query selector as you recall", + "start": 3227.819, + "duration": 6.181 + }, + { + "text": "just gets one element it's just going to", + "start": 3230.94, + "duration": 4.919 + }, + { + "text": "get for me a single element and it's", + "start": 3234.0, + "duration": 3.93 + }, + { + "text": "gonna get the first one that it finds if", + "start": 3235.859, + "duration": 4.2 + }, + { + "text": "I want to get multiple elements what I", + "start": 3237.93, + "duration": 3.899 + }, + { + "text": "can do instead is something like", + "start": 3240.059, + "duration": 6.24 + }, + { + "text": "document dot query selector all query", + "start": 3241.829, + "duration": 5.97 + }, + { + "text": "selector all is going to return the same", + "start": 3246.299, + "duration": 3.421 + }, + { + "text": "thing the query selector does but", + "start": 3247.799, + "duration": 3.391 + }, + { + "text": "instead of query selector returning a", + "start": 3249.72, + "duration": 3.089 + }, + { + "text": "single element that matches what it", + "start": 3251.19, + "duration": 4.079 + }, + { + "text": "looks for query selector all is going to", + "start": 3252.809, + "duration": 5.04 + }, + { + "text": "return to me an array of all of the", + "start": 3255.269, + "duration": 4.651 + }, + { + "text": "elements that match my particular query", + "start": 3257.849, + "duration": 4.051 + }, + { + "text": "so if I want to select not just the", + "start": 3259.92, + "duration": 3.899 + }, + { + "text": "first button I find but all of the", + "start": 3261.9, + "duration": 4.109 + }, + { + "text": "buttons I find I can here say query", + "start": 3263.819, + "duration": 4.591 + }, + { + "text": "selector all for button and that will", + "start": 3266.009, + "duration": 3.961 + }, + { + "text": "give me back a JavaScript array the", + "start": 3268.41, + "duration": 4.08 + }, + { + "text": "equivalent of a list that represents all", + "start": 3269.97, + "duration": 5.16 + }, + { + "text": "of those buttons and we can actually", + "start": 3272.49, + "duration": 4.619 + }, + { + "text": "test what this looks like by looking at", + "start": 3275.13, + "duration": 4.709 + }, + { + "text": "things inside of the JavaScript console", + "start": 3277.109, + "duration": 6.091 + }, + { + "text": "that if I go ahead and refresh this page", + "start": 3279.839, + "duration": 6.72 + }, + { + "text": "colors I can open up the inspector go", + "start": 3283.2, + "duration": 5.25 + }, + { + "text": "into the JavaScript console and just as", + "start": 3286.559, + "duration": 3.81 + }, + { + "text": "you could see error messages here you", + "start": 3288.45, + "duration": 4.619 + }, + { + "text": "can also actually write JavaScript code", + "start": 3290.369, + "duration": 5.611 + }, + { + "text": "here as well so I can say something like", + "start": 3293.069, + "duration": 8.04 + }, + { + "text": "document query selector button say all", + "start": 3295.98, + "duration": 7.26 + }, + { + "text": "right what's going to happen when I try", + "start": 3301.109, + "duration": 3.93 + }, + { + "text": "and select for a button on this", + "start": 3303.24, + "duration": 5.01 + }, + { + "text": "particular page and what I get is all", + "start": 3305.039, + "duration": 5.01 + }, + { + "text": "right I get just this very first button", + "start": 3308.25, + "duration": 4.529 + }, + { + "text": "button whose data - color is equal to", + "start": 3310.049, + "duration": 4.23 + }, + { + "text": "red that's what I would expect query", + "start": 3312.779, + "duration": 3.3 + }, + { + "text": "selector just finds me one element and", + "start": 3314.279, + "duration": 2.941 + }, + { + "text": "it's going to find me", + "start": 3316.079, + "duration": 4.2 + }, + { + "text": "the very first element and likewise I", + "start": 3317.22, + "duration": 3.69 + }, + { + "text": "can say all right", + "start": 3320.279, + "duration": 2.911 + }, + { + "text": "instead of query selector let's do query", + "start": 3320.91, + "duration": 5.159 + }, + { + "text": "selector all and what I get back is a", + "start": 3323.19, + "duration": 4.26 + }, + { + "text": "node list which you can think of as kind", + "start": 3326.069, + "duration": 3.181 + }, + { + "text": "of like an array or a list in Python", + "start": 3327.45, + "duration": 4.29 + }, + { + "text": "that's got three buttons in it button 0", + "start": 3329.25, + "duration": 5.759 + }, + { + "text": "1 and 2 and just as with a list in", + "start": 3331.74, + "duration": 4.799 + }, + { + "text": "Python as you can index into things", + "start": 3335.009, + "duration": 3.961 + }, + { + "text": "arrays and python arrays in JavaScript", + "start": 3336.539, + "duration": 4.23 + }, + { + "text": "can be indexed into as well but if I", + "start": 3338.97, + "duration": 3.66 + }, + { + "text": "have something like constant Eames", + "start": 3340.769, + "duration": 7.05 + }, + { + "text": "equals Harry Ron and Hermione like a", + "start": 3342.63, + "duration": 8.34 + }, + { + "text": "array of 3 names I can say name square", + "start": 3347.819, + "duration": 5.49 + }, + { + "text": "bracket 0 to get the first name name", + "start": 3350.97, + "duration": 3.869 + }, + { + "text": "square bracket 1 to get the second one", + "start": 3353.309, + "duration": 3.51 + }, + { + "text": "name square bracket 2 to get the third", + "start": 3354.839, + "duration": 2.401 + }, + { + "text": "one for", + "start": 3356.819, + "duration": 2.221 + }, + { + "text": "example and that gives me each of the", + "start": 3357.24, + "duration": 3.96 + }, + { + "text": "individual elements in the array if I", + "start": 3359.04, + "duration": 3.24 + }, + { + "text": "want to get the whole length of the", + "start": 3361.2, + "duration": 4.32 + }, + { + "text": "array I can do names dot lengths to get", + "start": 3362.28, + "duration": 5.43 + }, + { + "text": "all right the length of the names array", + "start": 3365.52, + "duration": 4.05 + }, + { + "text": "happens to be three so just some", + "start": 3367.71, + "duration": 3.15 + }, + { + "text": "additional features that we have access", + "start": 3369.57, + "duration": 3.27 + }, + { + "text": "to if you happen to have an array of", + "start": 3370.86, + "duration": 2.82 + }, + { + "text": "things", + "start": 3372.84, + "duration": 2.73 + }, + { + "text": "turns out query selector all returns to", + "start": 3373.68, + "duration": 3.42 + }, + { + "text": "me a node list which is kind of like an", + "start": 3375.57, + "duration": 3.63 + }, + { + "text": "array and that's going to be useful", + "start": 3377.1, + "duration": 4.65 + }, + { + "text": "because when I say document query", + "start": 3379.2, + "duration": 5.07 + }, + { + "text": "selector all button I am saying get me", + "start": 3381.75, + "duration": 5.73 + }, + { + "text": "all of the buttons on the page and now", + "start": 3384.27, + "duration": 5.13 + }, + { + "text": "what I would like to do is effectively", + "start": 3387.48, + "duration": 5.25 + }, + { + "text": "loop over all of those buttons and say", + "start": 3389.4, + "duration": 5.94 + }, + { + "text": "for each of the buttons inside of this", + "start": 3392.73, + "duration": 4.65 + }, + { + "text": "list that comes back to me I would like", + "start": 3395.34, + "duration": 4.56 + }, + { + "text": "to add an event handler for when that", + "start": 3397.38, + "duration": 4.2 + }, + { + "text": "button is clicked on to say for each of", + "start": 3399.9, + "duration": 3.6 + }, + { + "text": "the buttons that comes back go ahead and", + "start": 3401.58, + "duration": 3.63 + }, + { + "text": "say when you're clicked on change the", + "start": 3403.5, + "duration": 4.8 + }, + { + "text": "color of the h1 element and so there are", + "start": 3405.21, + "duration": 4.8 + }, + { + "text": "a number of ways again that you could do", + "start": 3408.3, + "duration": 5.55 + }, + { + "text": "this but one way is to use a particular", + "start": 3410.01, + "duration": 7.41 + }, + { + "text": "property called for each and for each is", + "start": 3413.85, + "duration": 6.09 + }, + { + "text": "a function that accepts as an argument", + "start": 3417.42, + "duration": 5.189 + }, + { + "text": "another function where the idea is going", + "start": 3419.94, + "duration": 5.04 + }, + { + "text": "to be I would like to run a function for", + "start": 3422.609, + "duration": 5.101 + }, + { + "text": "each of the elements inside of an array", + "start": 3424.98, + "duration": 5.82 + }, + { + "text": "or inside of a node list for example so", + "start": 3427.71, + "duration": 6.84 + }, + { + "text": "here I can say for each button go ahead", + "start": 3430.8, + "duration": 5.79 + }, + { + "text": "and run this function this is going to", + "start": 3434.55, + "duration": 3.72 + }, + { + "text": "be a function now that takes something", + "start": 3436.59, + "duration": 3.87 + }, + { + "text": "as input it's going to take one of the", + "start": 3438.27, + "duration": 4.26 + }, + { + "text": "elements in the list as input something", + "start": 3440.46, + "duration": 5.46 + }, + { + "text": "like a button and now for each button", + "start": 3442.53, + "duration": 5.96 + }, + { + "text": "what would I like to do for that button", + "start": 3445.92, + "duration": 5.43 + }, + { + "text": "well when the button is clicked on", + "start": 3448.49, + "duration": 6.1 + }, + { + "text": "button dot on click then go ahead and", + "start": 3451.35, + "duration": 9.269 + }, + { + "text": "run a function that is going to document", + "start": 3454.59, + "duration": 9.72 + }, + { + "text": "query selector get me the element whose", + "start": 3460.619, + "duration": 8.431 + }, + { + "text": "ID is hello change its style within the", + "start": 3464.31, + "duration": 7.14 + }, + { + "text": "style change its color and what do I", + "start": 3469.05, + "duration": 4.319 + }, + { + "text": "want to change its color to well I have", + "start": 3471.45, + "duration": 3.78 + }, + { + "text": "access to this button this argument to", + "start": 3473.369, + "duration": 3.961 + }, + { + "text": "the function is whichever button I'm", + "start": 3475.23, + "duration": 3.36 + }, + { + "text": "currently trying to add an event", + "start": 3477.33, + "duration": 3.84 + }, + { + "text": "listener for and in order to access its", + "start": 3478.59, + "duration": 4.89 + }, + { + "text": "data properties I can access a special", + "start": 3481.17, + "duration": 4.8 + }, + { + "text": "property of an HTML element called it's", + "start": 3483.48, + "duration": 5.04 + }, + { + "text": "a data set property and then I can say", + "start": 3485.97, + "duration": 4.8 + }, + { + "text": "something like button data set", + "start": 3488.52, + "duration": 4.95 + }, + { + "text": "color to get at the data - color", + "start": 3490.77, + "duration": 5.85 + }, + { + "text": "attribute so a lot of stuff going on", + "start": 3493.47, + "duration": 4.29 + }, + { + "text": "here let's go ahead and try and read", + "start": 3496.62, + "duration": 2.79 + }, + { + "text": "through this entire thing and just get a", + "start": 3497.76, + "duration": 2.88 + }, + { + "text": "feel for what's happening because we", + "start": 3499.41, + "duration": 2.91 + }, + { + "text": "have functions nested within other", + "start": 3500.64, + "duration": 3.42 + }, + { + "text": "functions nested within other functions", + "start": 3502.32, + "duration": 4.56 + }, + { + "text": "up at the very top I said add an event", + "start": 3504.06, + "duration": 4.77 + }, + { + "text": "listener to the document when the", + "start": 3506.88, + "duration": 3.99 + }, + { + "text": "documents Dom content is loaded meaning", + "start": 3508.83, + "duration": 3.6 + }, + { + "text": "all of the content of the page is done", + "start": 3510.87, + "duration": 3.96 + }, + { + "text": "loading go ahead and run this function", + "start": 3512.43, + "duration": 5.4 + }, + { + "text": "this is the body of the function so what", + "start": 3514.83, + "duration": 4.32 + }, + { + "text": "do I want to do when the page is done", + "start": 3517.83, + "duration": 3.48 + }, + { + "text": "loading I'm going to document dot query", + "start": 3519.15, + "duration": 4.65 + }, + { + "text": "selector all looking for all of the", + "start": 3521.31, + "duration": 4.74 + }, + { + "text": "buttons and if I wanted to if there", + "start": 3523.8, + "duration": 3.81 + }, + { + "text": "could be more buttons I could have added", + "start": 3526.05, + "duration": 3.24 + }, + { + "text": "a class to these buttons and just look", + "start": 3527.61, + "duration": 3.36 + }, + { + "text": "for things of the particular class query", + "start": 3529.29, + "duration": 3.3 + }, + { + "text": "selector all just returns all of the", + "start": 3530.97, + "duration": 3.48 + }, + { + "text": "elements that match a particular query", + "start": 3532.59, + "duration": 5.4 + }, + { + "text": "and then I'm saying for each of those", + "start": 3534.45, + "duration": 5.13 + }, + { + "text": "buttons for each of the buttons that", + "start": 3537.99, + "duration": 3.93 + }, + { + "text": "came back I would like to run a function", + "start": 3539.58, + "duration": 4.5 + }, + { + "text": "on each of those buttons I'm basically", + "start": 3541.92, + "duration": 3.66 + }, + { + "text": "saying if I have three buttons that came", + "start": 3544.08, + "duration": 3.36 + }, + { + "text": "back let me run a function on the first", + "start": 3545.58, + "duration": 3.48 + }, + { + "text": "button then the same function on the", + "start": 3547.44, + "duration": 3.39 + }, + { + "text": "second button then the same function on", + "start": 3549.06, + "duration": 3.57 + }, + { + "text": "the third button and what is that", + "start": 3550.83, + "duration": 4.2 + }, + { + "text": "function well it's this function here a", + "start": 3552.63, + "duration": 5.16 + }, + { + "text": "function that takes as input the button", + "start": 3555.03, + "duration": 4.41 + }, + { + "text": "its first gonna pass in as input the", + "start": 3557.79, + "duration": 3.45 + }, + { + "text": "first button then the second button then", + "start": 3559.44, + "duration": 4.47 + }, + { + "text": "the third and what this function does is", + "start": 3561.24, + "duration": 5.55 + }, + { + "text": "it adds an onclick handler to the button", + "start": 3563.91, + "duration": 5.28 + }, + { + "text": "it says when the button is clicked on go", + "start": 3566.79, + "duration": 4.26 + }, + { + "text": "ahead and run this other function and", + "start": 3569.19, + "duration": 3.9 + }, + { + "text": "this function now is the function that", + "start": 3571.05, + "duration": 3.93 + }, + { + "text": "will run when the button is clicked on", + "start": 3573.09, + "duration": 4.38 + }, + { + "text": "to say when the button is clicked on get", + "start": 3574.98, + "duration": 5.84 + }, + { + "text": "me the hello element change its color to", + "start": 3577.47, + "duration": 6.99 + }, + { + "text": "button dataset color and button dataset", + "start": 3580.82, + "duration": 5.95 + }, + { + "text": "that color takes a button takes an HTML", + "start": 3584.46, + "duration": 4.68 + }, + { + "text": "element like this one here and accesses", + "start": 3586.77, + "duration": 4.47 + }, + { + "text": "its data set all of its data properties", + "start": 3589.14, + "duration": 5.37 + }, + { + "text": "and specifically accesses the color data", + "start": 3591.24, + "duration": 5.1 + }, + { + "text": "property which in this case is equal to", + "start": 3594.51, + "duration": 3.45 + }, + { + "text": "red and that is what we would like to", + "start": 3596.34, + "duration": 4.98 + }, + { + "text": "set color equal to so a little bit more", + "start": 3597.96, + "duration": 4.41 + }, + { + "text": "complexity we've seen before", + "start": 3601.32, + "duration": 3.81 + }, + { + "text": "but now we've been able to reduce what", + "start": 3602.37, + "duration": 5.16 + }, + { + "text": "was three different event handlers into", + "start": 3605.13, + "duration": 4.74 + }, + { + "text": "just a single one and now this is going", + "start": 3607.53, + "duration": 4.14 + }, + { + "text": "to work the same way change it to red", + "start": 3609.87, + "duration": 4.8 + }, + { + "text": "blue and green all by just using those", + "start": 3611.67, + "duration": 4.83 + }, + { + "text": "data properties that we have access to", + "start": 3614.67, + "duration": 3.96 + }, + { + "text": "and so when in doubt about how these", + "start": 3616.5, + "duration": 3.48 + }, + { + "text": "things are working about what query", + "start": 3618.63, + "duration": 3.09 + }, + { + "text": "selector is returning the JavaScript", + "start": 3619.98, + "duration": 3.21 + }, + { + "text": "console can be a very powerful tool for", + "start": 3621.72, + "duration": 2.79 + }, + { + "text": "this so you can go into the JavaScript", + "start": 3623.19, + "duration": 1.89 + }, + { + "text": "console", + "start": 3624.51, + "duration": 2.49 + }, + { + "text": "and actually manipulate things you can", + "start": 3625.08, + "duration": 4.02 + }, + { + "text": "running run queries you can run", + "start": 3627.0, + "duration": 3.78 + }, + { + "text": "functions you can even modify their", + "start": 3629.1, + "duration": 3.66 + }, + { + "text": "values of variables like if I go back", + "start": 3630.78, + "duration": 5.49 + }, + { + "text": "for instance to counter dot HTML or head", + "start": 3632.76, + "duration": 6.27 + }, + { + "text": "this counter that's counting 0 1 2 3 4", + "start": 3636.27, + "duration": 5.22 + }, + { + "text": "if I wanted to I could say something", + "start": 3639.03, + "duration": 6.0 + }, + { + "text": "like counter equals 27 just like change", + "start": 3641.49, + "duration": 5.85 + }, + { + "text": "the value of the counter nothing appears", + "start": 3645.03, + "duration": 3.96 + }, + { + "text": "to have changed on the page I didn't say", + "start": 3647.34, + "duration": 3.96 + }, + { + "text": "update anything on the page but now next", + "start": 3648.99, + "duration": 4.02 + }, + { + "text": "time I run count it's going to update", + "start": 3651.3, + "duration": 3.9 + }, + { + "text": "the value of the count to 28 because I", + "start": 3653.01, + "duration": 3.84 + }, + { + "text": "had updated the value inside of the", + "start": 3655.2, + "duration": 3.3 + }, + { + "text": "JavaScript console it's going to", + "start": 3656.85, + "duration": 3.66 + }, + { + "text": "increment that value display that value", + "start": 3658.5, + "duration": 4.53 + }, + { + "text": "inside of the h1 element so you can", + "start": 3660.51, + "duration": 4.26 + }, + { + "text": "modify variables that you can run", + "start": 3663.03, + "duration": 4.56 + }, + { + "text": "functions you can run document query", + "start": 3664.77, + "duration": 4.23 + }, + { + "text": "selector to figure out what particular", + "start": 3667.59, + "duration": 3.3 + }, + { + "text": "elements are going to come back all", + "start": 3669.0, + "duration": 3.27 + }, + { + "text": "through the use of the javascript", + "start": 3670.89, + "duration": 3.33 + }, + { + "text": "console which can be a very very", + "start": 3672.27, + "duration": 3.81 + }, + { + "text": "powerful tool especially as you begin", + "start": 3674.22, + "duration": 3.99 + }, + { + "text": "working on trying to debug these", + "start": 3676.08, + "duration": 4.32 + }, + { + "text": "programs and trying to figure out what", + "start": 3678.21, + "duration": 4.26 + }, + { + "text": "might be wrong with them it turns out", + "start": 3680.4, + "duration": 3.51 + }, + { + "text": "too that there are other changes that we", + "start": 3682.47, + "duration": 3.09 + }, + { + "text": "can make in order to optimize our code a", + "start": 3683.91, + "duration": 3.03 + }, + { + "text": "little bit more in order to make it a", + "start": 3685.56, + "duration": 3.33 + }, + { + "text": "little bit more succinct and one way is", + "start": 3686.94, + "duration": 3.18 + }, + { + "text": "that in more recent versions of", + "start": 3688.89, + "duration": 2.49 + }, + { + "text": "JavaScript they've introduced a", + "start": 3690.12, + "duration": 3.3 + }, + { + "text": "particular notation for functions called", + "start": 3691.38, + "duration": 3.87 + }, + { + "text": "the arrow notation for functions and", + "start": 3693.42, + "duration": 3.18 + }, + { + "text": "I'll just show it to you because it'll", + "start": 3695.25, + "duration": 3.45 + }, + { + "text": "come up but often times instead of using", + "start": 3696.6, + "duration": 3.93 + }, + { + "text": "the keyword function before introducing", + "start": 3698.7, + "duration": 3.72 + }, + { + "text": "a function you'll just have something", + "start": 3700.53, + "duration": 6.63 + }, + { + "text": "like button and then arrow the curly", + "start": 3702.42, + "duration": 6.12 + }, + { + "text": "braces and strictly speaking you don't", + "start": 3707.16, + "duration": 2.67 + }, + { + "text": "even need the parentheses around the", + "start": 3708.54, + "duration": 3.99 + }, + { + "text": "input where button arrow and then in", + "start": 3709.83, + "duration": 4.74 + }, + { + "text": "these curly braces some code just means", + "start": 3712.53, + "duration": 3.48 + }, + { + "text": "here is going to be a function that", + "start": 3714.57, + "duration": 3.63 + }, + { + "text": "takes as input a variable called button", + "start": 3716.01, + "duration": 5.16 + }, + { + "text": "and then runs this particular block of", + "start": 3718.2, + "duration": 5.16 + }, + { + "text": "code when that function is run and", + "start": 3721.17, + "duration": 4.23 + }, + { + "text": "likewise if a function takes no input", + "start": 3723.36, + "duration": 3.75 + }, + { + "text": "like this function up here you could", + "start": 3725.4, + "duration": 3.6 + }, + { + "text": "express it using arrow notation with", + "start": 3727.11, + "duration": 5.37 + }, + { + "text": "just parentheses a arrow block and so", + "start": 3729.0, + "duration": 5.16 + }, + { + "text": "this is often a notation that you'll see", + "start": 3732.48, + "duration": 3.57 + }, + { + "text": "in Java scripts if you ever see it know", + "start": 3734.16, + "duration": 3.33 + }, + { + "text": "that that's really just shorthand for", + "start": 3736.05, + "duration": 3.09 + }, + { + "text": "creating a function whatever is to the", + "start": 3737.49, + "duration": 3.75 + }, + { + "text": "left of the arrow sign is the input to", + "start": 3739.14, + "duration": 3.66 + }, + { + "text": "the function and whatever is to the", + "start": 3741.24, + "duration": 3.3 + }, + { + "text": "right of the arrow is what code should", + "start": 3742.8, + "duration": 3.9 + }, + { + "text": "actually run when the function body gets", + "start": 3744.54, + "duration": 4.05 + }, + { + "text": "executed when the function is called", + "start": 3746.7, + "duration": 4.53 + }, + { + "text": "upon so what other changes might we want", + "start": 3748.59, + "duration": 5.13 + }, + { + "text": "to make two colors dot HTML well if we", + "start": 3751.23, + "duration": 4.41 + }, + { + "text": "look back at colors dot HTML here's what", + "start": 3753.72, + "duration": 3.21 + }, + { + "text": "it looks like now we've got a heading", + "start": 3755.64, + "duration": 2.78 + }, + { + "text": "that says hello and then", + "start": 3756.93, + "duration": 3.439 + }, + { + "text": "to change the color to red or blue or", + "start": 3758.42, + "duration": 4.439 + }, + { + "text": "green for example we might instead if we", + "start": 3760.369, + "duration": 4.381 + }, + { + "text": "want the user to choose from one from a", + "start": 3762.859, + "duration": 3.901 + }, + { + "text": "number of options decide upon the user", + "start": 3764.75, + "duration": 4.349 + }, + { + "text": "interface choice of using a drop-down", + "start": 3766.76, + "duration": 3.809 + }, + { + "text": "instead of a bunch of buttons for", + "start": 3769.099, + "duration": 3.45 + }, + { + "text": "example and JavaScript supports that as", + "start": 3770.569, + "duration": 3.061 + }, + { + "text": "well and we'll use this as an", + "start": 3772.549, + "duration": 2.911 + }, + { + "text": "opportunity to explore some of the other", + "start": 3773.63, + "duration": 3.719 + }, + { + "text": "event handlers that exist within", + "start": 3775.46, + "duration": 5.19 + }, + { + "text": "JavaScript so for example instead of", + "start": 3777.349, + "duration": 5.52 + }, + { + "text": "having these all inside of buttons I can", + "start": 3780.65, + "duration": 3.87 + }, + { + "text": "make my life a little bit easier by", + "start": 3782.869, + "duration": 4.351 + }, + { + "text": "making this a select drop-down where the", + "start": 3784.52, + "duration": 4.829 + }, + { + "text": "Select is going to have an option whose", + "start": 3787.22, + "duration": 4.139 + }, + { + "text": "value is I'll say black is the default", + "start": 3789.349, + "duration": 3.99 + }, + { + "text": "option and I'll say black and then we'll", + "start": 3791.359, + "duration": 3.871 + }, + { + "text": "add another option whose value is red", + "start": 3793.339, + "duration": 4.591 + }, + { + "text": "and then we say red and the value is", + "start": 3795.23, + "duration": 4.41 + }, + { + "text": "what we'll get in JavaScript when we try", + "start": 3797.93, + "duration": 3.149 + }, + { + "text": "and extract the value of a particular", + "start": 3799.64, + "duration": 3.719 + }, + { + "text": "select drop-down well it's in between", + "start": 3801.079, + "duration": 4.201 + }, + { + "text": "the option tags themselves is what the", + "start": 3803.359, + "duration": 3.631 + }, + { + "text": "user is going to see on the page when", + "start": 3805.28, + "duration": 2.7 + }, + { + "text": "they actually view it so I'm", + "start": 3806.99, + "duration": 3.569 + }, + { + "text": "capitalizing it just for them option", + "start": 3807.98, + "duration": 4.139 + }, + { + "text": "value equals blue", + "start": 3810.559, + "duration": 3.841 + }, + { + "text": "that'll be blue and then option value", + "start": 3812.119, + "duration": 5.43 + }, + { + "text": "equals green and that'll be green so now", + "start": 3814.4, + "duration": 5.429 + }, + { + "text": "what the user sees is they see hello and", + "start": 3817.549, + "duration": 3.78 + }, + { + "text": "then a drop-down menu where they can", + "start": 3819.829, + "duration": 3.54 + }, + { + "text": "choose from a list of colors rather than", + "start": 3821.329, + "duration": 4.5 + }, + { + "text": "click buttons in order to do so and now", + "start": 3823.369, + "duration": 4.44 + }, + { + "text": "of course this select drop-down doesn't", + "start": 3825.829, + "duration": 3.661 + }, + { + "text": "do anything at the moment but I can", + "start": 3827.809, + "duration": 4.591 + }, + { + "text": "modify it so that it does so now instead", + "start": 3829.49, + "duration": 4.92 + }, + { + "text": "of selecting for all of the buttons and", + "start": 3832.4, + "duration": 3.54 + }, + { + "text": "doing something with all the buttons we", + "start": 3834.41, + "duration": 3.419 + }, + { + "text": "don't have any buttons anymore what I do", + "start": 3835.94, + "duration": 6.75 + }, + { + "text": "have is I have a select drop-down and", + "start": 3837.829, + "duration": 7.411 + }, + { + "text": "now just as we've seen like on click to", + "start": 3842.69, + "duration": 3.96 + }, + { + "text": "say when you click on something as we've", + "start": 3845.24, + "duration": 3.089 + }, + { + "text": "seen Dom content loaded as an event", + "start": 3846.65, + "duration": 4.11 + }, + { + "text": "there's another event called on change", + "start": 3848.329, + "duration": 4.111 + }, + { + "text": "which applies to things like select", + "start": 3850.76, + "duration": 4.26 + }, + { + "text": "dropdowns where when something changes", + "start": 3852.44, + "duration": 3.899 + }, + { + "text": "in the select drop-down when a user", + "start": 3855.02, + "duration": 2.64 + }, + { + "text": "chooses something different", + "start": 3856.339, + "duration": 4.23 + }, + { + "text": "I can run some code for example so I can", + "start": 3857.66, + "duration": 5.1 + }, + { + "text": "run a function that in this case is", + "start": 3860.569, + "duration": 4.55 + }, + { + "text": "going to take document query selector", + "start": 3862.76, + "duration": 3.599 + }, + { + "text": "hello", + "start": 3865.119, + "duration": 3.48 + }, + { + "text": "meaning get me the hello HTML element", + "start": 3866.359, + "duration": 4.861 + }, + { + "text": "change its style what part of the style", + "start": 3868.599, + "duration": 4.96 + }, + { + "text": "changed its color and I want to change", + "start": 3871.22, + "duration": 3.66 + }, + { + "text": "it to something I want to change it to", + "start": 3873.559, + "duration": 5.04 + }, + { + "text": "the value of this select drop-down but", + "start": 3874.88, + "duration": 5.16 + }, + { + "text": "how do I get access to this particular", + "start": 3878.599, + "duration": 4.171 + }, + { + "text": "select drop-down well in JavaScript we", + "start": 3880.04, + "duration": 4.95 + }, + { + "text": "have access to a special value called", + "start": 3882.77, + "duration": 5.64 + }, + { + "text": "this and this has special meaning in", + "start": 3884.99, + "duration": 5.01 + }, + { + "text": "JavaScript and its meaning varies based", + "start": 3888.41, + "duration": 3.84 + }, + { + "text": "on context but in the context of an", + "start": 3890.0, + "duration": 3.96 + }, + { + "text": "event handler a function that is called", + "start": 3892.25, + "duration": 4.29 + }, + { + "text": "when a particular event happens this is", + "start": 3893.96, + "duration": 4.47 + }, + { + "text": "going to be a special keyword that", + "start": 3896.54, + "duration": 4.32 + }, + { + "text": "always refers to the thing that received", + "start": 3898.43, + "duration": 3.3 + }, + { + "text": "the event", + "start": 3900.86, + "duration": 2.85 + }, + { + "text": "so what received the event it was the", + "start": 3901.73, + "duration": 3.72 + }, + { + "text": "select drop-down that is what received", + "start": 3903.71, + "duration": 4.29 + }, + { + "text": "the event is being changed and so this", + "start": 3905.45, + "duration": 4.8 + }, + { + "text": "is going to be a special keyword that", + "start": 3908.0, + "duration": 4.17 + }, + { + "text": "always refers to that that always refers", + "start": 3910.25, + "duration": 4.05 + }, + { + "text": "to the drop-down menu where I made a", + "start": 3912.17, + "duration": 3.93 + }, + { + "text": "different selection so if I want to get", + "start": 3914.3, + "duration": 3.54 + }, + { + "text": "the value of that drop-down menu what it", + "start": 3916.1, + "duration": 4.14 + }, + { + "text": "is the user actually selected I can just", + "start": 3917.84, + "duration": 5.04 + }, + { + "text": "say this dot value to mean get that", + "start": 3920.24, + "duration": 4.74 + }, + { + "text": "drop-down menu and get at the value the", + "start": 3922.88, + "duration": 3.81 + }, + { + "text": "thing that the user is selected in that", + "start": 3924.98, + "duration": 4.08 + }, + { + "text": "idea and now much more succinctly than", + "start": 3926.69, + "duration": 4.92 + }, + { + "text": "before I've been able to implement the", + "start": 3929.06, + "duration": 4.56 + }, + { + "text": "same kind of idea says hello right now", + "start": 3931.61, + "duration": 3.66 + }, + { + "text": "in black but if I choose from the", + "start": 3933.62, + "duration": 3.48 + }, + { + "text": "drop-down menu to change its color to", + "start": 3935.27, + "duration": 3.72 + }, + { + "text": "something like red for example color", + "start": 3937.1, + "duration": 4.23 + }, + { + "text": "changes to red if I instead choose blue", + "start": 3938.99, + "duration": 4.59 + }, + { + "text": "it changes to blue green changes to", + "start": 3941.33, + "duration": 4.98 + }, + { + "text": "green I choose black it changes back to", + "start": 3943.58, + "duration": 5.04 + }, + { + "text": "black so now I have this ability to", + "start": 3946.31, + "duration": 4.11 + }, + { + "text": "detect these other types of events and", + "start": 3948.62, + "duration": 4.05 + }, + { + "text": "respond to them as well and there are", + "start": 3950.42, + "duration": 4.65 + }, + { + "text": "many many different events that exist in", + "start": 3952.67, + "duration": 4.2 + }, + { + "text": "JavaScript there's on-click which we've", + "start": 3955.07, + "duration": 4.2 + }, + { + "text": "seen already on mouse-over can detect", + "start": 3956.87, + "duration": 3.84 + }, + { + "text": "like when you mouse over something when", + "start": 3959.27, + "duration": 2.64 + }, + { + "text": "you're hovering over a particular", + "start": 3960.71, + "duration": 2.97 + }, + { + "text": "element if you've ever seen web sites", + "start": 3961.91, + "duration": 3.54 + }, + { + "text": "that somehow respond when your mouse", + "start": 3963.68, + "duration": 3.57 + }, + { + "text": "moves over something that can be how", + "start": 3965.45, + "duration": 4.29 + }, + { + "text": "it's implemented on key down and onkeyup", + "start": 3967.25, + "duration": 4.23 + }, + { + "text": "can respond to keyboard event something", + "start": 3969.74, + "duration": 4.32 + }, + { + "text": "like when you press a key on the", + "start": 3971.48, + "duration": 4.14 + }, + { + "text": "keyboard when you press down on the key", + "start": 3974.06, + "duration": 3.69 + }, + { + "text": "that's on key down and when you lift", + "start": 3975.62, + "duration": 3.9 + }, + { + "text": "your finger off the key that's on key up", + "start": 3977.75, + "duration": 4.14 + }, + { + "text": "and there are other events as well many", + "start": 3979.52, + "duration": 3.78 + }, + { + "text": "more events that are just listed here", + "start": 3981.89, + "duration": 3.93 + }, + { + "text": "that you can listen for and respond to", + "start": 3983.3, + "duration": 4.38 + }, + { + "text": "so that you can really interact with the", + "start": 3985.82, + "duration": 3.99 + }, + { + "text": "user based on what it is that they're", + "start": 3987.68, + "duration": 4.23 + }, + { + "text": "doing so now let's take a look at an", + "start": 3989.81, + "duration": 3.99 + }, + { + "text": "example of how we can use some of these", + "start": 3991.91, + "duration": 3.96 + }, + { + "text": "events to now begin to create a little", + "start": 3993.8, + "duration": 4.05 + }, + { + "text": "bit of a more interesting application", + "start": 3995.87, + "duration": 4.23 + }, + { + "text": "we'll go ahead and build a to-do list", + "start": 3997.85, + "duration": 4.1 + }, + { + "text": "application this time using exclusively", + "start": 4000.1, + "duration": 3.78 + }, + { + "text": "JavaScript we've seen to-do lists before", + "start": 4001.95, + "duration": 3.91 + }, + { + "text": "that involve communicating with a server", + "start": 4003.88, + "duration": 3.99 + }, + { + "text": "making requests and responses will now", + "start": 4005.86, + "duration": 4.08 + }, + { + "text": "build it to-do list that only uses", + "start": 4007.87, + "duration": 4.53 + }, + { + "text": "JavaScript to do so so I'll create a new", + "start": 4009.94, + "duration": 7.65 + }, + { + "text": "file called tasks HTML and we'll use a", + "start": 4012.4, + "duration": 7.5 + }, + { + "text": "we'll create a head section whose title", + "start": 4017.59, + "duration": 5.67 + }, + { + "text": "is tasks and a body section and inside", + "start": 4019.9, + "duration": 5.1 + }, + { + "text": "the body of the page I'll go ahead and", + "start": 4023.26, + "duration": 2.79 + }, + { + "text": "have a heading that says", + "start": 4025.0, + "duration": 4.08 + }, + { + "text": "tasks and underneath that I want an", + "start": 4026.05, + "duration": 5.46 + }, + { + "text": "unordered list of all of my tasks so", + "start": 4029.08, + "duration": 4.05 + }, + { + "text": "I'll have an unordered list I'll give it", + "start": 4031.51, + "duration": 3.9 + }, + { + "text": "an ID of tasks just for good measure so", + "start": 4033.13, + "duration": 4.05 + }, + { + "text": "I can reference it later but initially", + "start": 4035.41, + "duration": 4.32 + }, + { + "text": "nothing's going to be in here but what", + "start": 4037.18, + "duration": 4.08 + }, + { + "text": "I'll have underneath the unordered list", + "start": 4039.73, + "duration": 4.92 + }, + { + "text": "is a form a form where I can submit a", + "start": 4041.26, + "duration": 5.52 + }, + { + "text": "new task for example so I'll give myself", + "start": 4044.65, + "duration": 4.74 + }, + { + "text": "an input field also given an ID the ID", + "start": 4046.78, + "duration": 4.83 + }, + { + "text": "will be tasks singular for the new task", + "start": 4049.39, + "duration": 5.43 + }, + { + "text": "that I am typing in the placeholder will", + "start": 4051.61, + "duration": 5.1 + }, + { + "text": "be new tasks just so the user knows what", + "start": 4054.82, + "duration": 3.78 + }, + { + "text": "to type in and the type of the input", + "start": 4056.71, + "duration": 3.78 + }, + { + "text": "field will be text so I have an input", + "start": 4058.6, + "duration": 3.54 + }, + { + "text": "field where the user can type in some", + "start": 4060.49, + "duration": 3.84 + }, + { + "text": "new tasks and I'll also add an input", + "start": 4062.14, + "duration": 3.93 + }, + { + "text": "field for good measure whose type is", + "start": 4064.33, + "duration": 3.93 + }, + { + "text": "submit that allows the user to submit a", + "start": 4066.07, + "duration": 4.83 + }, + { + "text": "new task once they've created it so if I", + "start": 4068.26, + "duration": 6.09 + }, + { + "text": "open up tasks dot HTML here's then what", + "start": 4070.9, + "duration": 5.67 + }, + { + "text": "I see big heading there is technically", + "start": 4074.35, + "duration": 4.23 + }, + { + "text": "an unordered list underneath it here but", + "start": 4076.57, + "duration": 3.69 + }, + { + "text": "there's nothing in that unordered list", + "start": 4078.58, + "duration": 3.72 + }, + { + "text": "yet so it just shows up as empty then a", + "start": 4080.26, + "duration": 3.39 + }, + { + "text": "text field where I can type in a task", + "start": 4082.3, + "duration": 3.54 + }, + { + "text": "and then a submit button where I can", + "start": 4083.65, + "duration": 5.85 + }, + { + "text": "submit my new task so now I'd like some", + "start": 4085.84, + "duration": 5.25 + }, + { + "text": "JavaScript such that when I submit this", + "start": 4089.5, + "duration": 4.53 + }, + { + "text": "form we actually do something so add a", + "start": 4091.09, + "duration": 3.69 + }, + { + "text": "script tag", + "start": 4094.03, + "duration": 5.37 + }, + { + "text": "I want this JavaScript to run after the", + "start": 4094.78, + "duration": 8.94 + }, + { + "text": "Dom content is loaded so we'll go ahead", + "start": 4099.4, + "duration": 5.85 + }, + { + "text": "and add the usual Dom content loaded", + "start": 4103.72, + "duration": 4.65 + }, + { + "text": "event listener and now I want to run", + "start": 4105.25, + "duration": 5.91 + }, + { + "text": "code when the form is submitted so I can", + "start": 4108.37, + "duration": 7.949 + }, + { + "text": "say document query selector form dot on", + "start": 4111.16, + "duration": 7.77 + }, + { + "text": "submit equals and then I want to run a", + "start": 4116.319, + "duration": 4.29 + }, + { + "text": "function and I could use the keyword", + "start": 4118.93, + "duration": 2.88 + }, + { + "text": "function again but I can just use an", + "start": 4120.609, + "duration": 2.371 + }, + { + "text": "arrow function which would be a little", + "start": 4121.81, + "duration": 2.52 + }, + { + "text": "bit faster to type just say alright", + "start": 4122.98, + "duration": 3.39 + }, + { + "text": "here's the function that I want to run", + "start": 4124.33, + "duration": 4.56 + }, + { + "text": "when the form is submitted and what", + "start": 4126.37, + "duration": 4.44 + }, + { + "text": "would I like to do well I'd first like", + "start": 4128.89, + "duration": 3.33 + }, + { + "text": "to figure out alright what did the user", + "start": 4130.81, + "duration": 3.84 + }, + { + "text": "actually type in and what the user typed", + "start": 4132.22, + "duration": 4.59 + }, + { + "text": "in well that'll be document query", + "start": 4134.65, + "duration": 7.8 + }, + { + "text": "selector task dot value get me the", + "start": 4136.81, + "duration": 7.17 + }, + { + "text": "element with ID task that's the input", + "start": 4142.45, + "duration": 4.2 + }, + { + "text": "field dot value gets the value of the", + "start": 4143.98, + "duration": 3.99 + }, + { + "text": "input field which is what the user", + "start": 4146.65, + "duration": 4.439 + }, + { + "text": "actually typed in and I can save that as", + "start": 4147.97, + "duration": 6.96 + }, + { + "text": "like Const tasks that is what it is the", + "start": 4151.089, + "duration": 6.96 + }, + { + "text": "user typed in and if I'm curious as to", + "start": 4154.93, + "duration": 4.56 + }, + { + "text": "what the user typed in I can", + "start": 4158.049, + "duration": 3.991 + }, + { + "text": "actually print it out to the JavaScript", + "start": 4159.49, + "duration": 4.32 + }, + { + "text": "console and the way to do that is using", + "start": 4162.04, + "duration": 4.11 + }, + { + "text": "a special function called console.log", + "start": 4163.81, + "duration": 4.65 + }, + { + "text": "and that just logs something to the", + "start": 4166.15, + "duration": 3.63 + }, + { + "text": "console the equivalent of printing", + "start": 4168.46, + "duration": 2.7 + }, + { + "text": "something out in Python where just shows", + "start": 4169.78, + "duration": 3.24 + }, + { + "text": "up in the Python terminal here this is", + "start": 4171.16, + "duration": 3.42 + }, + { + "text": "going to show up in the JavaScript", + "start": 4173.02, + "duration": 4.11 + }, + { + "text": "console and one other thing I'll add is", + "start": 4174.58, + "duration": 4.89 + }, + { + "text": "by default forms will try and submit", + "start": 4177.13, + "duration": 3.57 + }, + { + "text": "when you press the submit button like", + "start": 4179.47, + "duration": 2.97 + }, + { + "text": "take you to another page we've seen this", + "start": 4180.7, + "duration": 3.45 + }, + { + "text": "before already in the context of Django", + "start": 4182.44, + "duration": 3.57 + }, + { + "text": "that when you submit a form it tries and", + "start": 4184.15, + "duration": 3.93 + }, + { + "text": "submits another web request if I want to", + "start": 4186.01, + "duration": 3.81 + }, + { + "text": "prevent that behavior stop the form from", + "start": 4188.08, + "duration": 3.69 + }, + { + "text": "submitting it's a stop form from", + "start": 4189.82, + "duration": 6.81 + }, + { + "text": "submitting I can return false at the end", + "start": 4191.77, + "duration": 6.78 + }, + { + "text": "of my form submission handler to say", + "start": 4196.63, + "duration": 3.66 + }, + { + "text": "don't actually submit the form we're", + "start": 4198.55, + "duration": 3.03 + }, + { + "text": "gonna do everything client-side", + "start": 4200.29, + "duration": 3.75 + }, + { + "text": "everything just inside of the browser so", + "start": 4201.58, + "duration": 3.93 + }, + { + "text": "now this won't quite work yet but it'll", + "start": 4204.04, + "duration": 3.6 + }, + { + "text": "be progress i refresh the page I'm gonna", + "start": 4205.51, + "duration": 3.63 + }, + { + "text": "open up the JavaScript console so I can", + "start": 4207.64, + "duration": 3.42 + }, + { + "text": "see what's going on if I add a task", + "start": 4209.14, + "duration": 4.52 + }, + { + "text": "something just like foo press submit", + "start": 4211.06, + "duration": 5.76 + }, + { + "text": "this now gets logged to the JavaScript", + "start": 4213.66, + "duration": 4.63 + }, + { + "text": "console it's the equivalent of a way of", + "start": 4216.82, + "duration": 3.18 + }, + { + "text": "like providing debugging information to", + "start": 4218.29, + "duration": 2.97 + }, + { + "text": "myself to know all right", + "start": 4220.0, + "duration": 3.96 + }, + { + "text": "I now have access to this value foo and", + "start": 4221.26, + "duration": 4.41 + }, + { + "text": "it's also telling me what line of code", + "start": 4223.96, + "duration": 4.77 + }, + { + "text": "logged it it was tasks HTML line 9 is", + "start": 4225.67, + "duration": 5.52 + }, + { + "text": "the line of code that logged foo and so", + "start": 4228.73, + "duration": 3.6 + }, + { + "text": "this can be useful when you're debugging", + "start": 4231.19, + "duration": 2.73 + }, + { + "text": "a program when you want to see what the", + "start": 4232.33, + "duration": 3.51 + }, + { + "text": "values of variables are you can just", + "start": 4233.92, + "duration": 4.23 + }, + { + "text": "print them out using console log to", + "start": 4235.84, + "duration": 3.45 + }, + { + "text": "figure out what's going on in your", + "start": 4238.15, + "duration": 3.71 + }, + { + "text": "program and any particular point in time", + "start": 4239.29, + "duration": 5.1 + }, + { + "text": "but what I want to do is not console dot", + "start": 4241.86, + "duration": 4.39 + }, + { + "text": "log n what I want to do is really create", + "start": 4244.39, + "duration": 4.86 + }, + { + "text": "a new element that I'm going to add into", + "start": 4246.25, + "duration": 6.06 + }, + { + "text": "my body of the HTML so how can I do that", + "start": 4249.25, + "duration": 5.07 + }, + { + "text": "well to create a new element for my", + "start": 4252.31, + "duration": 3.9 + }, + { + "text": "document I can run a function called", + "start": 4254.32, + "duration": 5.4 + }, + { + "text": "document dot create element followed by", + "start": 4256.21, + "duration": 5.34 + }, + { + "text": "what type of element do I want to create", + "start": 4259.72, + "duration": 4.68 + }, + { + "text": "well I have an unordered list a ul and", + "start": 4261.55, + "duration": 5.01 + }, + { + "text": "every item inside of an unordered list", + "start": 4264.4, + "duration": 5.25 + }, + { + "text": "is a list item in Li so I'll go ahead", + "start": 4266.56, + "duration": 6.59 + }, + { + "text": "and create an Li element a list item and", + "start": 4269.65, + "duration": 6.48 + }, + { + "text": "I'll save that in a variable that I'll", + "start": 4273.15, + "duration": 6.34 + }, + { + "text": "call Li so I've created a new list item", + "start": 4276.13, + "duration": 7.44 + }, + { + "text": "and this list items inner HTML the HTML", + "start": 4279.49, + "duration": 6.81 + }, + { + "text": "content inside of that list item well", + "start": 4283.57, + "duration": 5.04 + }, + { + "text": "that's just going to be tasks this", + "start": 4286.3, + "duration": 4.26 + }, + { + "text": "variable from up here which is whatever", + "start": 4288.61, + "duration": 4.65 + }, + { + "text": "the user typed in so I've now created", + "start": 4290.56, + "duration": 5.52 + }, + { + "text": "newest item and said what GML should go", + "start": 4293.26, + "duration": 4.35 + }, + { + "text": "inside of the list item it should be", + "start": 4296.08, + "duration": 4.35 + }, + { + "text": "whatever task the user typed in and now", + "start": 4297.61, + "duration": 5.91 + }, + { + "text": "I'm going to say document dot query", + "start": 4300.43, + "duration": 6.03 + }, + { + "text": "selector tasks get me the element whose", + "start": 4303.52, + "duration": 5.04 + }, + { + "text": "ideas tasks and that's gonna be this", + "start": 4306.46, + "duration": 4.05 + }, + { + "text": "unordered list here the unordered list", + "start": 4308.56, + "duration": 4.86 + }, + { + "text": "whose ideas tasks and if I have an HTML", + "start": 4310.51, + "duration": 5.58 + }, + { + "text": "element I can add a new element inside", + "start": 4313.42, + "duration": 7.86 + }, + { + "text": "of it by saying dot append Li and with", + "start": 4316.09, + "duration": 7.02 + }, + { + "text": "that now is going to do is it's going to", + "start": 4321.28, + "duration": 3.48 + }, + { + "text": "say get me the unordered list whose", + "start": 4323.11, + "duration": 3.39 + }, + { + "text": "ideas tasks get me the element whose", + "start": 4324.76, + "duration": 3.63 + }, + { + "text": "ideas tasks by a query selector here", + "start": 4326.5, + "duration": 4.71 + }, + { + "text": "once I have that element append to the", + "start": 4328.39, + "duration": 4.49 + }, + { + "text": "end of what's inside of that element", + "start": 4331.21, + "duration": 5.13 + }, + { + "text": "this value Li which happens to be this", + "start": 4332.88, + "duration": 5.56 + }, + { + "text": "new element that I've created a new list", + "start": 4336.34, + "duration": 4.5 + }, + { + "text": "item so I've been able to add a new HTML", + "start": 4338.44, + "duration": 4.35 + }, + { + "text": "element and this line of code is going", + "start": 4340.84, + "duration": 4.11 + }, + { + "text": "to say add it to the Dom add it to the", + "start": 4342.79, + "duration": 3.9 + }, + { + "text": "unordered list that I am here now", + "start": 4344.95, + "duration": 7.77 + }, + { + "text": "constructing so now I rerun this I see", + "start": 4346.69, + "duration": 7.71 + }, + { + "text": "tasks I type in something like foo I", + "start": 4352.72, + "duration": 4.17 + }, + { + "text": "press submit and alright foo now shows", + "start": 4354.4, + "duration": 3.99 + }, + { + "text": "up I type in something like a right to", + "start": 4356.89, + "duration": 3.93 + }, + { + "text": "leave that type in bar bar now shows up", + "start": 4358.39, + "duration": 5.19 + }, + { + "text": "I'd have been Baz Baz no shows up now", + "start": 4360.82, + "duration": 4.59 + }, + { + "text": "one minor user interface annoyance is", + "start": 4363.58, + "duration": 3.27 + }, + { + "text": "that it seems that every time I submit a", + "start": 4365.41, + "duration": 4.35 + }, + { + "text": "new task this input field retains the", + "start": 4366.85, + "duration": 4.89 + }, + { + "text": "value of what it used to be and that's", + "start": 4369.76, + "duration": 3.84 + }, + { + "text": "probably not what I want because I'd", + "start": 4371.74, + "duration": 3.21 + }, + { + "text": "rather it just clear out I've already", + "start": 4373.6, + "duration": 2.7 + }, + { + "text": "submitted the task no need for it to", + "start": 4374.95, + "duration": 3.27 + }, + { + "text": "stay there but that's easy to manipulate", + "start": 4376.3, + "duration": 4.17 + }, + { + "text": "in JavaScript if I want to clear out", + "start": 4378.22, + "duration": 4.2 + }, + { + "text": "this input field the input field whose", + "start": 4380.47, + "duration": 4.98 + }, + { + "text": "ID is task then all I need to do is say", + "start": 4382.42, + "duration": 6.93 + }, + { + "text": "document dot query selector task get me", + "start": 4385.45, + "duration": 6.96 + }, + { + "text": "that input field change its value equal", + "start": 4389.35, + "duration": 5.46 + }, + { + "text": "to the empty string equal to nothing", + "start": 4392.41, + "duration": 4.89 + }, + { + "text": "just to say clear out the value of what", + "start": 4394.81, + "duration": 4.02 + }, + { + "text": "happens to be inside of that input field", + "start": 4397.3, + "duration": 3.81 + }, + { + "text": "right now and now if i refresh the page", + "start": 4398.83, + "duration": 5.22 + }, + { + "text": "type in foo press submit input field", + "start": 4401.11, + "duration": 4.71 + }, + { + "text": "clears out and now I can type in", + "start": 4404.05, + "duration": 3.6 + }, + { + "text": "something like bar and then something", + "start": 4405.82, + "duration": 4.11 + }, + { + "text": "like Baz to continue to add tasks as", + "start": 4407.65, + "duration": 4.89 + }, + { + "text": "well now one thing that might be", + "start": 4409.93, + "duration": 3.6 + }, + { + "text": "slightly annoying is that I'm not", + "start": 4412.54, + "duration": 3.48 + }, + { + "text": "careful if I press submit well it", + "start": 4413.53, + "duration": 4.74 + }, + { + "text": "submits the empty string is a task and", + "start": 4416.02, + "duration": 4.14 + }, + { + "text": "so I just get this empty bullet point", + "start": 4418.27, + "duration": 4.02 + }, + { + "text": "that shows up here nice press submit and", + "start": 4420.16, + "duration": 3.81 + }, + { + "text": "I just get all of these empty bullet", + "start": 4422.29, + "duration": 3.24 + }, + { + "text": "points it might be nice from a user", + "start": 4423.97, + "duration": 2.939 + }, + { + "text": "experience perspective", + "start": 4425.53, + "duration": 3.45 + }, + { + "text": "if I were to not allow the user to do", + "start": 4426.909, + "duration": 4.141 + }, + { + "text": "that not allow them to submit a task if", + "start": 4428.98, + "duration": 3.719 + }, + { + "text": "they haven't actually typed something in", + "start": 4431.05, + "duration": 4.26 + }, + { + "text": "to the new task field and we can do that", + "start": 4432.699, + "duration": 4.951 + }, + { + "text": "just by modifying properties of elements", + "start": 4435.31, + "duration": 4.02 + }, + { + "text": "that it turns out that HTML elements", + "start": 4437.65, + "duration": 4.319 + }, + { + "text": "have a property called disabled that can", + "start": 4439.33, + "duration": 4.47 + }, + { + "text": "be true or false that allows us to", + "start": 4441.969, + "duration": 5.371 + }, + { + "text": "disable something like a button so if I", + "start": 4443.8, + "duration": 6.21 + }, + { + "text": "want to disable the submit button one", + "start": 4447.34, + "duration": 4.35 + }, + { + "text": "thing I might want to do first is give", + "start": 4450.01, + "duration": 3.99 + }, + { + "text": "this submit button an ID I'll give it an", + "start": 4451.69, + "duration": 4.77 + }, + { + "text": "ID of submit so that in my JavaScript", + "start": 4454.0, + "duration": 4.38 + }, + { + "text": "code I can reference the submit button", + "start": 4456.46, + "duration": 6.23 + }, + { + "text": "and now inside of this JavaScript code", + "start": 4458.38, + "duration": 7.83 + }, + { + "text": "when the Dom content is loaded by", + "start": 4462.69, + "duration": 7.38 + }, + { + "text": "default the submit button should be", + "start": 4466.21, + "duration": 6.239 + }, + { + "text": "disabled like when I first load the page", + "start": 4470.07, + "duration": 4.39 + }, + { + "text": "I don't want the submit button to be", + "start": 4472.449, + "duration": 3.361 + }, + { + "text": "enabled because I want the user to type", + "start": 4474.46, + "duration": 3.54 + }, + { + "text": "in a task first before I enable the", + "start": 4475.81, + "duration": 4.679 + }, + { + "text": "submit button so how do I do that well I", + "start": 4478.0, + "duration": 4.949 + }, + { + "text": "can document query selector get me the", + "start": 4480.489, + "duration": 4.261 + }, + { + "text": "element whose ID is submit get me that", + "start": 4482.949, + "duration": 3.571 + }, + { + "text": "submit button and just said it's", + "start": 4484.75, + "duration": 3.92 + }, + { + "text": "disabled property equal to true", + "start": 4486.52, + "duration": 4.29 + }, + { + "text": "javascript has boolean values true and", + "start": 4488.67, + "duration": 4.45 + }, + { + "text": "false I set the disabled value equal to", + "start": 4490.81, + "duration": 5.55 + }, + { + "text": "true to disable the submit button now if", + "start": 4493.12, + "duration": 5.19 + }, + { + "text": "i refresh the page I can type in a new", + "start": 4496.36, + "duration": 3.87 + }, + { + "text": "task but the submit button is disabled", + "start": 4498.31, + "duration": 3.659 + }, + { + "text": "it doesn't do anything now obviously I", + "start": 4500.23, + "duration": 2.969 + }, + { + "text": "don't want to keep it that way I'd like", + "start": 4501.969, + "duration": 2.701 + }, + { + "text": "it such that as I begin to type things", + "start": 4503.199, + "duration": 3.991 + }, + { + "text": "in then the submit button stops being", + "start": 4504.67, + "duration": 4.59 + }, + { + "text": "disabled disabled get set from true to", + "start": 4507.19, + "duration": 5.16 + }, + { + "text": "false instead and so what I really want", + "start": 4509.26, + "duration": 6.209 + }, + { + "text": "to do is listen for me like pressing", + "start": 4512.35, + "duration": 6.059 + }, + { + "text": "keys on the keyboard and so the way I", + "start": 4515.469, + "duration": 5.19 + }, + { + "text": "can do that is by adding yet another", + "start": 4518.409, + "duration": 5.571 + }, + { + "text": "event listener document query selector", + "start": 4520.659, + "duration": 5.58 + }, + { + "text": "what I want to add a query selector to", + "start": 4523.98, + "duration": 3.46 + }, + { + "text": "what do I want to add an event handler", + "start": 4526.239, + "duration": 3.391 + }, + { + "text": "for well I want to add an event handler", + "start": 4527.44, + "duration": 4.049 + }, + { + "text": "for when I type something into this", + "start": 4529.63, + "duration": 4.47 + }, + { + "text": "input field and this input field has an", + "start": 4531.489, + "duration": 5.4 + }, + { + "text": "ID of tasks so let me go ahead and get", + "start": 4534.1, + "duration": 4.59 + }, + { + "text": "the input field the element whose ideas", + "start": 4536.889, + "duration": 5.58 + }, + { + "text": "tasks and add an on key up handler on", + "start": 4538.69, + "duration": 6.36 + }, + { + "text": "key up again is the event when I lift my", + "start": 4542.469, + "duration": 6.27 + }, + { + "text": "finger off of a key go ahead and run", + "start": 4545.05, + "duration": 5.91 + }, + { + "text": "this function and what should the", + "start": 4548.739, + "duration": 3.811 + }, + { + "text": "function do well it's going to say", + "start": 4550.96, + "duration": 4.65 + }, + { + "text": "document query selector submit set the", + "start": 4552.55, + "duration": 5.97 + }, + { + "text": "disabled property equal to false", + "start": 4555.61, + "duration": 5.13 + }, + { + "text": "and so now here's what we're doing we're", + "start": 4558.52, + "duration": 4.02 + }, + { + "text": "saying by default when I first load the", + "start": 4560.74, + "duration": 4.59 + }, + { + "text": "page take the submit button and disable", + "start": 4562.54, + "duration": 5.55 + }, + { + "text": "it said dot disabled equal to true then", + "start": 4565.33, + "duration": 5.52 + }, + { + "text": "anytime I type a key and my finger comes", + "start": 4568.09, + "duration": 4.95 + }, + { + "text": "off the key that means on key up is the", + "start": 4570.85, + "duration": 4.02 + }, + { + "text": "event that gets triggered run this", + "start": 4573.04, + "duration": 3.69 + }, + { + "text": "function and what the function is going", + "start": 4574.87, + "duration": 3.99 + }, + { + "text": "to do is take that same submit button", + "start": 4576.73, + "duration": 4.41 + }, + { + "text": "and set its disabled property equal to", + "start": 4578.86, + "duration": 4.32 + }, + { + "text": "false so now instead of being disabled", + "start": 4581.14, + "duration": 6.54 + }, + { + "text": "it will be enabled so if I go back to", + "start": 4583.18, + "duration": 6.87 + }, + { + "text": "the page go here I type in it right now", + "start": 4587.68, + "duration": 4.2 + }, + { + "text": "by default the submit button is disabled", + "start": 4590.05, + "duration": 4.29 + }, + { + "text": "but as soon as I start typing something", + "start": 4591.88, + "duration": 4.77 + }, + { + "text": "now the submit button is active and I", + "start": 4594.34, + "duration": 5.4 + }, + { + "text": "can actually click on it and all right", + "start": 4596.65, + "duration": 4.92 + }, + { + "text": "this isn't great because I clicked on it", + "start": 4599.74, + "duration": 3.36 + }, + { + "text": "but the submit button is still enabled", + "start": 4601.57, + "duration": 3.33 + }, + { + "text": "so what I might like to do is all right", + "start": 4603.1, + "duration": 3.72 + }, + { + "text": "after I've submitted the forum after", + "start": 4604.9, + "duration": 3.84 + }, + { + "text": "I've added a new task let's go back and", + "start": 4606.82, + "duration": 5.0 + }, + { + "text": "disable the submit button so after I've", + "start": 4608.74, + "duration": 6.15 + }, + { + "text": "submitted the form after we've added the", + "start": 4611.82, + "duration": 5.23 + }, + { + "text": "new task to my list of tasks after we've", + "start": 4614.89, + "duration": 4.08 + }, + { + "text": "cleared out the value from the input", + "start": 4617.05, + "duration": 5.64 + }, + { + "text": "field let me also get the submit button", + "start": 4618.97, + "duration": 6.72 + }, + { + "text": "set it's disabled property equal to true", + "start": 4622.69, + "duration": 5.76 + }, + { + "text": "now even after I submit the form the", + "start": 4625.69, + "duration": 4.2 + }, + { + "text": "submit button is still going to be", + "start": 4628.45, + "duration": 3.87 + }, + { + "text": "disabled such that I type in foo now", + "start": 4629.89, + "duration": 4.56 + }, + { + "text": "submit is active I press it but the", + "start": 4632.32, + "duration": 3.39 + }, + { + "text": "submit button goes back to being", + "start": 4634.45, + "duration": 4.38 + }, + { + "text": "inactive as well it turns out that even", + "start": 4635.71, + "duration": 4.77 + }, + { + "text": "now there's still a little bit of a bug", + "start": 4638.83, + "duration": 2.88 + }, + { + "text": "if I go back here and I type in", + "start": 4640.48, + "duration": 4.44 + }, + { + "text": "something like bar but then I backspace", + "start": 4641.71, + "duration": 6.06 + }, + { + "text": "back to like nothing here the submit", + "start": 4644.92, + "duration": 4.17 + }, + { + "text": "button is still active so I can still", + "start": 4647.77, + "duration": 3.57 + }, + { + "text": "technically submit a task that has no", + "start": 4649.09, + "duration": 4.47 + }, + { + "text": "content inside of it and so I might like", + "start": 4651.34, + "duration": 3.9 + }, + { + "text": "to have some way of preventing against", + "start": 4653.56, + "duration": 3.54 + }, + { + "text": "that as well and that's just some", + "start": 4655.24, + "duration": 3.42 + }, + { + "text": "additional logic we now have access to", + "start": 4657.1, + "duration": 3.36 + }, + { + "text": "JavaScript that has conditions that has", + "start": 4658.66, + "duration": 4.2 + }, + { + "text": "loops that has functions and so if I", + "start": 4660.46, + "duration": 5.82 + }, + { + "text": "want to do something like conditionally", + "start": 4662.86, + "duration": 6.75 + }, + { + "text": "check I can say if document query", + "start": 4666.28, + "duration": 8.66 + }, + { + "text": "selector task dot value dot length is", + "start": 4669.61, + "duration": 8.37 + }, + { + "text": "greater than 0 meaning like something's", + "start": 4674.94, + "duration": 5.83 + }, + { + "text": "actually typed into the task field will", + "start": 4677.98, + "duration": 6.47 + }, + { + "text": "then go ahead and set disabled to false", + "start": 4680.77, + "duration": 7.1 + }, + { + "text": "but otherwise", + "start": 4684.45, + "duration": 3.42 + }, + { + "text": "go ahead and set disabled equal the true", + "start": 4688.69, + "duration": 6.31 + }, + { + "text": "so now here we're checking if the length", + "start": 4692.11, + "duration": 4.57 + }, + { + "text": "of what the user has typed in is greater", + "start": 4695.0, + "duration": 3.3 + }, + { + "text": "than zero they actually type something", + "start": 4696.68, + "duration": 3.72 + }, + { + "text": "in then yes give them access to the", + "start": 4698.3, + "duration": 4.53 + }, + { + "text": "submit button but otherwise don't give", + "start": 4700.4, + "duration": 4.83 + }, + { + "text": "them access to that button so now i", + "start": 4702.83, + "duration": 4.77 + }, + { + "text": "refresh the page disabled by default I", + "start": 4705.23, + "duration": 4.47 + }, + { + "text": "typed something in it's enabled I delete", + "start": 4707.6, + "duration": 4.56 + }, + { + "text": "delete delete and it goes back to being", + "start": 4709.7, + "duration": 4.95 + }, + { + "text": "disabled so javascript has allowed us to", + "start": 4712.16, + "duration": 4.11 + }, + { + "text": "really make our pages much more", + "start": 4714.65, + "duration": 3.45 + }, + { + "text": "interactive and immediately interactive", + "start": 4716.27, + "duration": 3.69 + }, + { + "text": "based on how the user is interacting", + "start": 4718.1, + "duration": 3.72 + }, + { + "text": "with the page as they begin to type", + "start": 4719.96, + "duration": 4.56 + }, + { + "text": "things as they begin to delete things as", + "start": 4721.82, + "duration": 4.59 + }, + { + "text": "they press buttons we're able to have", + "start": 4724.52, + "duration": 3.63 + }, + { + "text": "the page respond either by adding", + "start": 4726.41, + "duration": 3.78 + }, + { + "text": "content to the Dom by literally adding", + "start": 4728.15, + "duration": 4.56 + }, + { + "text": "parts to the HTML page of changing the", + "start": 4730.19, + "duration": 4.11 + }, + { + "text": "styles of things changing particular", + "start": 4732.71, + "duration": 3.42 + }, + { + "text": "properties of elements and this is", + "start": 4734.3, + "duration": 3.12 + }, + { + "text": "really where the power of JavaScript", + "start": 4736.13, + "duration": 3.3 + }, + { + "text": "begins to come in isn't allowing", + "start": 4737.42, + "duration": 5.52 + }, + { + "text": "ourselves to do things like that now so", + "start": 4739.43, + "duration": 5.31 + }, + { + "text": "far we've only been able to have events", + "start": 4742.94, + "duration": 4.41 + }, + { + "text": "happen when the user does something when", + "start": 4744.74, + "duration": 4.5 + }, + { + "text": "the user clicks on a button or when the", + "start": 4747.35, + "duration": 3.96 + }, + { + "text": "user presses a key for example but it", + "start": 4749.24, + "duration": 4.02 + }, + { + "text": "turns out JavaScript has other ways of", + "start": 4751.31, + "duration": 3.93 + }, + { + "text": "allowing functions to run in fact on", + "start": 4753.26, + "duration": 3.54 + }, + { + "text": "their own we can set what are called", + "start": 4755.24, + "duration": 3.27 + }, + { + "text": "intervals where a particular function", + "start": 4756.8, + "duration": 4.08 + }, + { + "text": "runs every some number of milliseconds", + "start": 4758.51, + "duration": 4.41 + }, + { + "text": "for example and so if we go back to like", + "start": 4760.88, + "duration": 3.8 + }, + { + "text": "the counter example from before right", + "start": 4762.92, + "duration": 4.89 + }, + { + "text": "now for this counter example I have to", + "start": 4764.68, + "duration": 4.54 + }, + { + "text": "be the one to press the count button", + "start": 4767.81, + "duration": 3.12 + }, + { + "text": "that is going to increment the value of", + "start": 4769.22, + "duration": 4.62 + }, + { + "text": "count every single time but I could put", + "start": 4770.93, + "duration": 5.34 + }, + { + "text": "that inside of an interval instead so", + "start": 4773.84, + "duration": 3.96 + }, + { + "text": "let me go back to counter", + "start": 4776.27, + "duration": 4.05 + }, + { + "text": "dot HTML whose JavaScript is inside of", + "start": 4777.8, + "duration": 6.0 + }, + { + "text": "counter j/s and now what I'd like to say", + "start": 4780.32, + "duration": 8.52 + }, + { + "text": "is I would like when the Dom content is", + "start": 4783.8, + "duration": 11.04 + }, + { + "text": "loaded let me set an interval for count", + "start": 4788.84, + "duration": 10.8 + }, + { + "text": "and 1000 so what is that going to do set", + "start": 4794.84, + "duration": 6.27 + }, + { + "text": "interval as a function built into", + "start": 4799.64, + "duration": 3.57 + }, + { + "text": "JavaScript here where I'm saying that I", + "start": 4801.11, + "duration": 3.42 + }, + { + "text": "would like to create a new interval", + "start": 4803.21, + "duration": 3.54 + }, + { + "text": "where every so often go ahead and run a", + "start": 4804.53, + "duration": 4.32 + }, + { + "text": "particular function and I would like to", + "start": 4806.75, + "duration": 3.9 + }, + { + "text": "run the count function will recall that", + "start": 4808.85, + "duration": 3.75 + }, + { + "text": "count function is going to increment the", + "start": 4810.65, + "duration": 3.48 + }, + { + "text": "value of count and I'll get rid of this", + "start": 4812.6, + "duration": 3.24 + }, + { + "text": "alert for now just for simplicity all I", + "start": 4814.13, + "duration": 3.87 + }, + { + "text": "want the count function to do is update", + "start": 4815.84, + "duration": 4.17 + }, + { + "text": "the h1 with the new value of the counter", + "start": 4818.0, + "duration": 2.78 + }, + { + "text": "and", + "start": 4820.01, + "duration": 1.91 + }, + { + "text": "go ahead and run that count function", + "start": 4820.78, + "duration": 3.66 + }, + { + "text": "every 1000 milliseconds otherwise known", + "start": 4821.92, + "duration": 5.25 + }, + { + "text": "as every one second go ahead and run the", + "start": 4824.44, + "duration": 5.179 + }, + { + "text": "count function so now when I open", + "start": 4827.17, + "duration": 6.659 + }, + { + "text": "counter dot HTML it's zero but every", + "start": 4829.619, + "duration": 5.741 + }, + { + "text": "second now it's going to change every", + "start": 4833.829, + "duration": 3.511 + }, + { + "text": "second updating one by one by one I", + "start": 4835.36, + "duration": 3.509 + }, + { + "text": "don't have to click the button of course", + "start": 4837.34, + "duration": 2.91 + }, + { + "text": "I could and the event handler would", + "start": 4838.869, + "duration": 3.181 + }, + { + "text": "still work but the interval is saying", + "start": 4840.25, + "duration": 4.829 + }, + { + "text": "now every one second go ahead and run", + "start": 4842.05, + "duration": 4.68 + }, + { + "text": "the count function and that has this", + "start": 4845.079, + "duration": 3.241 + }, + { + "text": "particular result so if you've ever seen", + "start": 4846.73, + "duration": 3.449 + }, + { + "text": "a webpage that like displays the current", + "start": 4848.32, + "duration": 3.48 + }, + { + "text": "time in seconds and like a countdown", + "start": 4850.179, + "duration": 3.571 + }, + { + "text": "timer or is displaying the current time", + "start": 4851.8, + "duration": 3.75 + }, + { + "text": "with seconds it might be doing something", + "start": 4853.75, + "duration": 3.15 + }, + { + "text": "like this just having some sort of", + "start": 4855.55, + "duration": 3.54 + }, + { + "text": "interval that every second is going to", + "start": 4856.9, + "duration": 4.02 + }, + { + "text": "count and increment in order to say", + "start": 4859.09, + "duration": 3.75 + }, + { + "text": "update the number to the one greater one", + "start": 4860.92, + "duration": 3.92 + }, + { + "text": "greater and one greater than that of", + "start": 4862.84, + "duration": 5.19 + }, + { + "text": "course if I close the page and go back", + "start": 4864.84, + "duration": 5.379 + }, + { + "text": "to it if I close these pages and then", + "start": 4868.03, + "duration": 5.279 + }, + { + "text": "open counter dot HTML again I've gone", + "start": 4870.219, + "duration": 5.161 + }, + { + "text": "back to zero like JavaScript is not", + "start": 4873.309, + "duration": 4.83 + }, + { + "text": "saving any state about my page it's just", + "start": 4875.38, + "duration": 5.1 + }, + { + "text": "every time we're running the page it's", + "start": 4878.139, + "duration": 5.131 + }, + { + "text": "going to go back to counter j/s it's", + "start": 4880.48, + "duration": 4.02 + }, + { + "text": "going to say all right we're defining a", + "start": 4883.27, + "duration": 2.82 + }, + { + "text": "variable called counter we're setting", + "start": 4884.5, + "duration": 3.719 + }, + { + "text": "that variable equal to zero so every", + "start": 4886.09, + "duration": 3.299 + }, + { + "text": "time I load the page it's going to be", + "start": 4888.219, + "duration": 3.57 + }, + { + "text": "set back to zero and that might not be", + "start": 4889.389, + "duration": 4.23 + }, + { + "text": "great depending on the type of page", + "start": 4891.789, + "duration": 3.301 + }, + { + "text": "you're trying to create that maybe you", + "start": 4893.619, + "duration": 3.571 + }, + { + "text": "want to page that is somehow able to", + "start": 4895.09, + "duration": 4.17 + }, + { + "text": "store information such that on", + "start": 4897.19, + "duration": 3.779 + }, + { + "text": "subsequent visits were able to utilize", + "start": 4899.26, + "duration": 3.779 + }, + { + "text": "the information that was already stored", + "start": 4900.969, + "duration": 4.351 + }, + { + "text": "some way of remembering information for", + "start": 4903.039, + "duration": 4.651 + }, + { + "text": "later use in later versions of", + "start": 4905.32, + "duration": 4.23 + }, + { + "text": "JavaScript and more modern browsers now", + "start": 4907.69, + "duration": 3.69 + }, + { + "text": "allow us to do something just like that", + "start": 4909.55, + "duration": 4.109 + }, + { + "text": "called local storage and what local", + "start": 4911.38, + "duration": 4.469 + }, + { + "text": "storage is is it's a way for us to be", + "start": 4913.659, + "duration": 4.471 + }, + { + "text": "able to store information inside of the", + "start": 4915.849, + "duration": 4.35 + }, + { + "text": "user's web browser that a page can ask", + "start": 4918.13, + "duration": 4.259 + }, + { + "text": "to store particular values inside the", + "start": 4920.199, + "duration": 4.44 + }, + { + "text": "web browser and later on on subsequent", + "start": 4922.389, + "duration": 4.321 + }, + { + "text": "visits to that page we can go back and", + "start": 4924.639, + "duration": 4.111 + }, + { + "text": "say let's extract those values that were", + "start": 4926.71, + "duration": 4.679 + }, + { + "text": "previously stored inside of local", + "start": 4928.75, + "duration": 4.98 + }, + { + "text": "storage local storage it's going to give", + "start": 4931.389, + "duration": 4.201 + }, + { + "text": "us access to two key functions that", + "start": 4933.73, + "duration": 3.3 + }, + { + "text": "we're going to use to manipulate this", + "start": 4935.59, + "duration": 2.129 + }, + { + "text": "local storage", + "start": 4937.03, + "duration": 3.72 + }, + { + "text": "the first is local storage getitem where", + "start": 4937.719, + "duration": 4.44 + }, + { + "text": "we would like to get something out of", + "start": 4940.75, + "duration": 3.869 + }, + { + "text": "local storage based on its key some name", + "start": 4942.159, + "duration": 4.471 + }, + { + "text": "that we have given to that value and we", + "start": 4944.619, + "duration": 3.96 + }, + { + "text": "also have access to local storage dot", + "start": 4946.63, + "duration": 4.409 + }, + { + "text": "set item which goes ahead and adds a new", + "start": 4948.579, + "duration": 4.261 + }, + { + "text": "value to local storage or replaces an", + "start": 4951.039, + "duration": 3.301 + }, + { + "text": "existing value in local storage", + "start": 4952.84, + "duration": 4.65 + }, + { + "text": "setting this key equal to a particular", + "start": 4954.34, + "duration": 5.73 + }, + { + "text": "value so we can use local storage then", + "start": 4957.49, + "duration": 4.83 + }, + { + "text": "to allow our webpages using javascript", + "start": 4960.07, + "duration": 4.2 + }, + { + "text": "to be able to store information and", + "start": 4962.32, + "duration": 4.02 + }, + { + "text": "retrieve information from the browser", + "start": 4964.27, + "duration": 4.38 + }, + { + "text": "and let's now try to use that in order", + "start": 4966.34, + "duration": 6.09 + }, + { + "text": "to solve this problem of the counter", + "start": 4968.65, + "duration": 6.05 + }, + { + "text": "that seems to always reset back to zero", + "start": 4972.43, + "duration": 5.01 + }, + { + "text": "so now in counter jeaious instead of", + "start": 4974.7, + "duration": 4.72 + }, + { + "text": "sending counter equal to zero the first", + "start": 4977.44, + "duration": 4.41 + }, + { + "text": "thing I want to know is is there already", + "start": 4979.42, + "duration": 5.22 + }, + { + "text": "a value for the counter in local storage", + "start": 4981.85, + "duration": 6.75 + }, + { + "text": "so I can ask a question like if local", + "start": 4984.64, + "duration": 8.28 + }, + { + "text": "storage dot get item counter meaning go", + "start": 4988.6, + "duration": 7.05 + }, + { + "text": "to local storage try and get the counter", + "start": 4992.92, + "duration": 5.67 + }, + { + "text": "and anything in this if expression will", + "start": 4995.65, + "duration": 5.34 + }, + { + "text": "happen if there is something inside of", + "start": 4998.59, + "duration": 4.41 + }, + { + "text": "local storage for counter but it turns", + "start": 5000.99, + "duration": 3.36 + }, + { + "text": "out that if I want to do the inverse of", + "start": 5003.0, + "duration": 3.15 + }, + { + "text": "that say not I can just use the", + "start": 5004.35, + "duration": 3.72 + }, + { + "text": "exclamation point much like in C in", + "start": 5006.15, + "duration": 3.69 + }, + { + "text": "JavaScript the exclamation point just", + "start": 5008.07, + "duration": 4.23 + }, + { + "text": "means not so meaning if there is not", + "start": 5009.84, + "duration": 4.35 + }, + { + "text": "something in local storage called", + "start": 5012.3, + "duration": 4.2 + }, + { + "text": "counter well then let's go ahead and", + "start": 5014.19, + "duration": 4.17 + }, + { + "text": "just set the value in local storage", + "start": 5016.5, + "duration": 5.64 + }, + { + "text": "local storage dot set item counter and", + "start": 5018.36, + "duration": 6.48 + }, + { + "text": "we'll set it equal to zero so what this", + "start": 5022.14, + "duration": 4.65 + }, + { + "text": "is doing here is before anything else", + "start": 5024.84, + "duration": 4.32 + }, + { + "text": "happens we are checking local storage to", + "start": 5026.79, + "duration": 5.09 + }, + { + "text": "say is there already a value for counter", + "start": 5029.16, + "duration": 5.34 + }, + { + "text": "and if there is not already a value for", + "start": 5031.88, + "duration": 4.21 + }, + { + "text": "counter we need to make sure there is", + "start": 5034.5, + "duration": 3.03 + }, + { + "text": "something there inside of local storage", + "start": 5036.09, + "duration": 3.09 + }, + { + "text": "for the counter so we are going to set", + "start": 5037.53, + "duration": 4.29 + }, + { + "text": "the value of counter equal to zero for", + "start": 5039.18, + "duration": 5.37 + }, + { + "text": "example and so now what needs to change", + "start": 5041.82, + "duration": 4.35 + }, + { + "text": "I'll go ahead and get rid of the", + "start": 5044.55, + "duration": 3.33 + }, + { + "text": "interval so that it only happens when I", + "start": 5046.17, + "duration": 3.6 + }, + { + "text": "click on it but what should this count", + "start": 5047.88, + "duration": 4.44 + }, + { + "text": "function actually do well first let me", + "start": 5049.77, + "duration": 5.37 + }, + { + "text": "get the value of the counter counter is", + "start": 5052.32, + "duration": 5.79 + }, + { + "text": "going to be whatever local storage get", + "start": 5055.14, + "duration": 5.67 + }, + { + "text": "item counter is I'm gonna get the", + "start": 5058.11, + "duration": 5.37 + }, + { + "text": "counter out of local storage I'm going", + "start": 5060.81, + "duration": 5.31 + }, + { + "text": "to increment it counter plus plus we'll", + "start": 5063.48, + "duration": 4.89 + }, + { + "text": "go ahead and set the value of this h1", + "start": 5066.12, + "duration": 3.51 + }, + { + "text": "elements innerhtml", + "start": 5068.37, + "duration": 3.96 + }, + { + "text": "equal to that counter but the last step", + "start": 5069.63, + "duration": 5.37 + }, + { + "text": "is I'll also do local storage dot set", + "start": 5072.33, + "duration": 6.36 + }, + { + "text": "item counter is equal to the new value", + "start": 5075.0, + "duration": 7.29 + }, + { + "text": "of counter so what I've done here is to", + "start": 5078.69, + "duration": 5.73 + }, + { + "text": "say that when I click the button count", + "start": 5082.29, + "duration": 3.93 + }, + { + "text": "function is going to run we're first", + "start": 5084.42, + "duration": 3.84 + }, + { + "text": "going to go into local storage get", + "start": 5086.22, + "duration": 4.5 + }, + { + "text": "value for the key counter whatever the", + "start": 5088.26, + "duration": 4.35 + }, + { + "text": "value of counter happens to be save it", + "start": 5090.72, + "duration": 3.27 + }, + { + "text": "inside of this variable called counter", + "start": 5092.61, + "duration": 3.03 + }, + { + "text": "we'll go ahead and increment that", + "start": 5093.99, + "duration": 3.54 + }, + { + "text": "variable setting it equal to itself plus", + "start": 5095.64, + "duration": 5.07 + }, + { + "text": "one update the h1s innerhtml same as", + "start": 5097.53, + "duration": 4.56 + }, + { + "text": "before just to update what we actually", + "start": 5100.71, + "duration": 4.38 + }, + { + "text": "see on the page but then go ahead and", + "start": 5102.09, + "duration": 6.15 + }, + { + "text": "local storage set item counter gets set", + "start": 5105.09, + "duration": 8.13 + }, + { + "text": "to counter for example so now let's go", + "start": 5108.24, + "duration": 9.15 + }, + { + "text": "ahead and see what's going to happen if", + "start": 5113.22, + "duration": 7.44 + }, + { + "text": "I go ahead and open counter dot HTML we", + "start": 5117.39, + "duration": 7.71 + }, + { + "text": "see 0 we count 1 2 3 4 5 everything so", + "start": 5120.66, + "duration": 6.54 + }, + { + "text": "far so good now watch what happens if i", + "start": 5125.1, + "duration": 5.15 + }, + { + "text": "refresh this page i refresh the page and", + "start": 5127.2, + "duration": 4.95 + }, + { + "text": "alright that seems a little bit strange", + "start": 5130.25, + "duration": 4.42 + }, + { + "text": "at 0 let me try counting and see what", + "start": 5132.15, + "duration": 4.77 + }, + { + "text": "happens i press count and alright the", + "start": 5134.67, + "duration": 4.8 + }, + { + "text": "count changed to 6 so it seems like it", + "start": 5136.92, + "duration": 4.56 + }, + { + "text": "did remember that i counted up to 5 0 1", + "start": 5139.47, + "duration": 4.23 + }, + { + "text": "2 3 4 5 but when i refresh the page it", + "start": 5141.48, + "duration": 4.38 + }, + { + "text": "still showed me 0 but then let me count", + "start": 5143.7, + "duration": 3.6 + }, + { + "text": "up to the number 6 and I can keep", + "start": 5145.86, + "duration": 3.78 + }, + { + "text": "counting 7 8 9 10 what happens if i", + "start": 5147.3, + "duration": 3.93 + }, + { + "text": "refresh the page now I can try it i", + "start": 5149.64, + "duration": 4.77 + }, + { + "text": "refresh the page I've gone back to 0 but", + "start": 5151.23, + "duration": 5.25 + }, + { + "text": "I count and okay now I'm at 11 so", + "start": 5154.41, + "duration": 3.96 + }, + { + "text": "somehow I am still remembering but the", + "start": 5156.48, + "duration": 3.6 + }, + { + "text": "first time it's still giving me 0 every", + "start": 5158.37, + "duration": 4.5 + }, + { + "text": "time why might that be well if you look", + "start": 5160.08, + "duration": 5.01 + }, + { + "text": "back at counter dot HTML you'll notice", + "start": 5162.87, + "duration": 3.87 + }, + { + "text": "that the reason is just inside the body", + "start": 5165.09, + "duration": 3.81 + }, + { + "text": "of the page the initial value of the h1", + "start": 5166.74, + "duration": 4.5 + }, + { + "text": "is just always 0 so if I want to fix", + "start": 5168.9, + "duration": 4.26 + }, + { + "text": "that then what I need the same is when", + "start": 5171.24, + "duration": 4.11 + }, + { + "text": "the Dom content is loaded go ahead and", + "start": 5173.16, + "duration": 5.97 + }, + { + "text": "get document query selector h1 go ahead", + "start": 5175.35, + "duration": 5.34 + }, + { + "text": "and update the innerhtml", + "start": 5179.13, + "duration": 6.68 + }, + { + "text": "equal to whatever local storage get item", + "start": 5180.69, + "duration": 8.16 + }, + { + "text": "counter happens to be so every time I", + "start": 5185.81, + "duration": 5.17 + }, + { + "text": "open the page even before I click the", + "start": 5188.85, + "duration": 3.87 + }, + { + "text": "button even before the event listener is", + "start": 5190.98, + "duration": 3.6 + }, + { + "text": "triggered I'd like to say go ahead and", + "start": 5192.72, + "duration": 3.78 + }, + { + "text": "replace this heading update its inner", + "start": 5194.58, + "duration": 4.95 + }, + { + "text": "HTML to be the result of getting the", + "start": 5196.5, + "duration": 5.54 + }, + { + "text": "counter out of local storage for example", + "start": 5199.53, + "duration": 5.76 + }, + { + "text": "so now for refresh the page it's all at", + "start": 5202.04, + "duration": 5.38 + }, + { + "text": "11 I can update update update click", + "start": 5205.29, + "duration": 4.32 + }, + { + "text": "again some number of times bring it up", + "start": 5207.42, + "duration": 4.47 + }, + { + "text": "to 18 for example refresh the page and", + "start": 5209.61, + "duration": 4.35 + }, + { + "text": "it stays at the number 18 and no matter", + "start": 5211.89, + "duration": 3.72 + }, + { + "text": "what value I get it to it's going to", + "start": 5213.96, + "duration": 3.27 + }, + { + "text": "store that number inside of local", + "start": 5215.61, + "duration": 3.51 + }, + { + "text": "storage such that when i refresh the", + "start": 5217.23, + "duration": 4.349 + }, + { + "text": "page that number is going to stay there", + "start": 5219.12, + "duration": 4.229 + }, + { + "text": "we can actually see the value inside of", + "start": 5221.579, + "duration": 3.721 + }, + { + "text": "local storage but again going into", + "start": 5223.349, + "duration": 4.98 + }, + { + "text": "Chrome's inspector I go into Chrome if I", + "start": 5225.3, + "duration": 6.419 + }, + { + "text": "go to the application tab and I go to", + "start": 5228.329, + "duration": 6.3 + }, + { + "text": "local storage here on the Left I can see", + "start": 5231.719, + "duration": 4.47 + }, + { + "text": "that I have a value for key counter", + "start": 5234.629, + "duration": 3.48 + }, + { + "text": "whose value in this case happens to be", + "start": 5236.189, + "duration": 3.54 + }, + { + "text": "28 and you could go into local storage", + "start": 5238.109, + "duration": 3.27 + }, + { + "text": "you can manipulate this value you could", + "start": 5239.729, + "duration": 3.27 + }, + { + "text": "delete it if you want but this just goes", + "start": 5241.379, + "duration": 3.12 + }, + { + "text": "to show you that we have now stored this", + "start": 5242.999, + "duration": 4.41 + }, + { + "text": "value inside of my browser such that on", + "start": 5244.499, + "duration": 4.68 + }, + { + "text": "subsequent visits if this page gets", + "start": 5247.409, + "duration": 3.81 + }, + { + "text": "loaded again we can access that value", + "start": 5249.179, + "duration": 4.55 + }, + { + "text": "from inside of the application as well", + "start": 5251.219, + "duration": 5.07 + }, + { + "text": "and so now we've been able to see how", + "start": 5253.729, + "duration": 4.45 + }, + { + "text": "our pages are able to store data in", + "start": 5256.289, + "duration": 3.84 + }, + { + "text": "order to just make the user experience a", + "start": 5258.179, + "duration": 3.42 + }, + { + "text": "little bit better if we want the user to", + "start": 5260.129, + "duration": 3.39 + }, + { + "text": "be able to have information remembered", + "start": 5261.599, + "duration": 3.9 + }, + { + "text": "from the last time they visited a", + "start": 5263.519, + "duration": 3.33 + }, + { + "text": "particular page we can sometimes", + "start": 5265.499, + "duration": 5.04 + }, + { + "text": "actually be quite helpful all right so", + "start": 5266.849, + "duration": 4.92 + }, + { + "text": "now we've seen a lot of features of", + "start": 5270.539, + "duration": 3.0 + }, + { + "text": "JavaScript we've seen a bunch of", + "start": 5271.769, + "duration": 3.301 + }, + { + "text": "different ways of representing data we", + "start": 5273.539, + "duration": 3.39 + }, + { + "text": "store data in variables and those", + "start": 5275.07, + "duration": 3.48 + }, + { + "text": "variables have had types like integers", + "start": 5276.929, + "duration": 3.9 + }, + { + "text": "those variables of sum has been strings", + "start": 5278.55, + "duration": 4.409 + }, + { + "text": "and some times have been HTML elements", + "start": 5280.829, + "duration": 4.471 + }, + { + "text": "sometimes they've been arrays or lists", + "start": 5282.959, + "duration": 4.051 + }, + { + "text": "of our items sometimes they've even been", + "start": 5285.3, + "duration": 3.359 + }, + { + "text": "functions so we can set a variable equal", + "start": 5287.01, + "duration": 3.569 + }, + { + "text": "to a function but perhaps one of the", + "start": 5288.659, + "duration": 4.32 + }, + { + "text": "most useful data types inside of", + "start": 5290.579, + "duration": 5.73 + }, + { + "text": "JavaScript is the JavaScript object so", + "start": 5292.979, + "duration": 4.801 + }, + { + "text": "go into the JavaScript console just to", + "start": 5296.309, + "duration": 3.451 + }, + { + "text": "demonstrate this what the JavaScript", + "start": 5297.78, + "duration": 4.529 + }, + { + "text": "object is is it's really the equivalent", + "start": 5299.76, + "duration": 4.799 + }, + { + "text": "of like a Python dictionary some", + "start": 5302.309, + "duration": 5.07 + }, + { + "text": "Association of keys to values where you", + "start": 5304.559, + "duration": 4.44 + }, + { + "text": "can look up something by a key or by a", + "start": 5307.379, + "duration": 4.651 + }, + { + "text": "property and see what his value happens", + "start": 5308.999, + "duration": 6.0 + }, + { + "text": "to be so if I had a variable like person", + "start": 5312.03, + "duration": 5.909 + }, + { + "text": "I could set person equal to a JavaScript", + "start": 5314.999, + "duration": 6.42 + }, + { + "text": "object who's like first name is Harry", + "start": 5317.939, + "duration": 7.65 + }, + { + "text": "and whose last name is Potter again", + "start": 5321.419, + "duration": 6.93 + }, + { + "text": "using syntax very similar to what the", + "start": 5325.589, + "duration": 5.04 + }, + { + "text": "dictionary syntax looks like inside of", + "start": 5328.349, + "duration": 4.86 + }, + { + "text": "Python as well and now that I have this", + "start": 5330.629, + "duration": 5.01 + }, + { + "text": "variable person which is first Harry", + "start": 5333.209, + "duration": 4.95 + }, + { + "text": "last Potter I can access a particular", + "start": 5335.639, + "duration": 4.08 + }, + { + "text": "property of the person in a number of", + "start": 5338.159, + "duration": 3.51 + }, + { + "text": "ways I can say something like person dot", + "start": 5339.719, + "duration": 3.78 + }, + { + "text": "first to say get me the first name", + "start": 5341.669, + "duration": 4.56 + }, + { + "text": "property of this particular object and I", + "start": 5343.499, + "duration": 4.59 + }, + { + "text": "see that it's equal to Harry I could", + "start": 5346.229, + "duration": 3.66 + }, + { + "text": "equivalently use square bracket notation", + "start": 5348.089, + "duration": 3.961 + }, + { + "text": "the way Python does square bracket first", + "start": 5349.889, + "duration": 4.29 + }, + { + "text": "and that will also give me Harry", + "start": 5352.05, + "duration": 4.53 + }, + { + "text": "but this turns out to be quite powerful", + "start": 5354.179, + "duration": 4.741 + }, + { + "text": "to be able to represent data in this", + "start": 5356.58, + "duration": 4.23 + }, + { + "text": "structured way like this where I have an", + "start": 5358.92, + "duration": 3.63 + }, + { + "text": "association of keys or otherwise known", + "start": 5360.81, + "duration": 4.11 + }, + { + "text": "as properties with particular values and", + "start": 5362.55, + "duration": 4.02 + }, + { + "text": "then I have the ability given a", + "start": 5364.92, + "duration": 4.23 + }, + { + "text": "JavaScript object to be able to access a", + "start": 5366.57, + "duration": 4.68 + }, + { + "text": "particular value and it turns out that", + "start": 5369.15, + "duration": 3.93 + }, + { + "text": "one of the ways this is most useful is", + "start": 5371.25, + "duration": 4.14 + }, + { + "text": "in the exchange of data moving data", + "start": 5373.08, + "duration": 5.07 + }, + { + "text": "around from one service to another and", + "start": 5375.39, + "duration": 4.65 + }, + { + "text": "so here we're going to introduce what", + "start": 5378.15, + "duration": 3.81 + }, + { + "text": "are known as api's otherwise known as", + "start": 5380.04, + "duration": 4.26 + }, + { + "text": "application programming interfaces which", + "start": 5381.96, + "duration": 4.41 + }, + { + "text": "in the context of the web you can think", + "start": 5384.3, + "duration": 4.14 + }, + { + "text": "of as some well-defined structured way", + "start": 5386.37, + "duration": 4.26 + }, + { + "text": "for services on the Internet to", + "start": 5388.44, + "duration": 4.11 + }, + { + "text": "communicate with each other that if you", + "start": 5390.63, + "duration": 4.02 + }, + { + "text": "want your application to be able to talk", + "start": 5392.55, + "duration": 3.899 + }, + { + "text": "to some other service maybe you want", + "start": 5394.65, + "duration": 3.72 + }, + { + "text": "your application to interact with Google", + "start": 5396.449, + "duration": 3.361 + }, + { + "text": "Maps or to be able to interact with", + "start": 5398.37, + "duration": 3.3 + }, + { + "text": "Amazon or some other weather service to", + "start": 5399.81, + "duration": 3.48 + }, + { + "text": "get the day's weather then you might be", + "start": 5401.67, + "duration": 4.23 + }, + { + "text": "able to access some API some mechanism", + "start": 5403.29, + "duration": 4.409 + }, + { + "text": "whereby you can communicate with another", + "start": 5405.9, + "duration": 3.72 + }, + { + "text": "service by sending a request and", + "start": 5407.699, + "duration": 4.351 + }, + { + "text": "receiving back data in some sort of very", + "start": 5409.62, + "duration": 4.89 + }, + { + "text": "well structured format and very often", + "start": 5412.05, + "duration": 4.56 + }, + { + "text": "that well structured format happens to", + "start": 5414.51, + "duration": 4.05 + }, + { + "text": "be a particular type of data known as", + "start": 5416.61, + "duration": 3.96 + }, + { + "text": "Jason which stands for JavaScript object", + "start": 5418.56, + "duration": 4.679 + }, + { + "text": "notation which is a way of transferring", + "start": 5420.57, + "duration": 6.0 + }, + { + "text": "data in the form of JavaScript objects", + "start": 5423.239, + "duration": 5.611 + }, + { + "text": "these sort of objects that happen to", + "start": 5426.57, + "duration": 4.47 + }, + { + "text": "have properties and values associated", + "start": 5428.85, + "duration": 4.74 + }, + { + "text": "with them and so what does javascript", + "start": 5431.04, + "duration": 4.29 + }, + { + "text": "object notation look like well if we", + "start": 5433.59, + "duration": 3.0 + }, + { + "text": "think back to the applications that", + "start": 5435.33, + "duration": 2.67 + }, + { + "text": "we've been creating these applications", + "start": 5436.59, + "duration": 2.97 + }, + { + "text": "that are able to represent things like", + "start": 5438.0, + "duration": 4.17 + }, + { + "text": "an airline and many movements of planes", + "start": 5439.56, + "duration": 4.38 + }, + { + "text": "between particular destinations a", + "start": 5442.17, + "duration": 4.41 + }, + { + "text": "JavaScript object representing a flight", + "start": 5443.94, + "duration": 4.32 + }, + { + "text": "might look something like this", + "start": 5446.58, + "duration": 3.48 + }, + { + "text": "a JavaScript object that has properties", + "start": 5448.26, + "duration": 4.74 + }, + { + "text": "for origin is something destination is", + "start": 5450.06, + "duration": 4.889 + }, + { + "text": "something duration is something things", + "start": 5453.0, + "duration": 3.84 + }, + { + "text": "we've seen before but you might imagine", + "start": 5454.949, + "duration": 4.02 + }, + { + "text": "that if we wanted our airline to be able", + "start": 5456.84, + "duration": 3.87 + }, + { + "text": "to make its data available to other", + "start": 5458.969, + "duration": 3.811 + }, + { + "text": "services so that other web applications", + "start": 5460.71, + "duration": 4.35 + }, + { + "text": "or other programs could programmatically", + "start": 5462.78, + "duration": 4.5 + }, + { + "text": "access information about flights we", + "start": 5465.06, + "duration": 5.07 + }, + { + "text": "could pass data in this format to those", + "start": 5467.28, + "duration": 5.01 + }, + { + "text": "other applications so that they could", + "start": 5470.13, + "duration": 3.779 + }, + { + "text": "then treat this as a JavaScript object", + "start": 5472.29, + "duration": 3.84 + }, + { + "text": "and get access to the information about", + "start": 5473.909, + "duration": 3.631 + }, + { + "text": "it and the nice thing about this", + "start": 5476.13, + "duration": 3.839 + }, + { + "text": "particular representation is that it is", + "start": 5477.54, + "duration": 4.86 + }, + { + "text": "both human readable and machine readable", + "start": 5479.969, + "duration": 4.17 + }, + { + "text": "that we as people can look at this and", + "start": 5482.4, + "duration": 3.48 + }, + { + "text": "get an intuitive understanding for what", + "start": 5484.139, + "duration": 3.901 + }, + { + "text": "all of this means but also a computer", + "start": 5485.88, + "duration": 3.84 + }, + { + "text": "knows how to access particular", + "start": 5488.04, + "duration": 3.18 + }, + { + "text": "properties that appear before the colon", + "start": 5489.72, + "duration": 3.96 + }, + { + "text": "and get access to what those values are", + "start": 5491.22, + "duration": 5.67 + }, + { + "text": "which appear after that colon as well so", + "start": 5493.68, + "duration": 5.25 + }, + { + "text": "JavaScript object notation otherwise", + "start": 5496.89, + "duration": 4.2 + }, + { + "text": "known as jason offers a very convenient", + "start": 5498.93, + "duration": 4.08 + }, + { + "text": "representation and this isn't exactly", + "start": 5501.09, + "duration": 4.8 + }, + { + "text": "what the JavaScript object syntax is in", + "start": 5503.01, + "duration": 4.5 + }, + { + "text": "JavaScript objects you don't strictly", + "start": 5505.89, + "duration": 3.3 + }, + { + "text": "need the quotation marks around the keys", + "start": 5507.51, + "duration": 3.66 + }, + { + "text": "you could just say origin colon and not", + "start": 5509.19, + "duration": 4.11 + }, + { + "text": "origin in quotation marks so JavaScript", + "start": 5511.17, + "duration": 4.35 + }, + { + "text": "object notation uses slightly different", + "start": 5513.3, + "duration": 4.44 + }, + { + "text": "syntax but ultimately very reminiscent", + "start": 5515.52, + "duration": 3.93 + }, + { + "text": "what we've seen in JavaScript objects", + "start": 5517.74, + "duration": 3.81 + }, + { + "text": "and JavaScript knows how to take data in", + "start": 5519.45, + "duration": 3.99 + }, + { + "text": "this form and turn it into something", + "start": 5521.55, + "duration": 3.81 + }, + { + "text": "like a JavaScript object and turns out", + "start": 5523.44, + "duration": 3.42 + }, + { + "text": "there ways of doing this in Python as", + "start": 5525.36, + "duration": 3.09 + }, + { + "text": "well in other programming languages have", + "start": 5526.86, + "duration": 4.41 + }, + { + "text": "the ability to interpret JSON data in", + "start": 5528.45, + "duration": 4.89 + }, + { + "text": "order to use it in some meaningful way", + "start": 5531.27, + "duration": 4.44 + }, + { + "text": "and another advantage of the JSON", + "start": 5533.34, + "duration": 4.38 + }, + { + "text": "representation is it is very conducive", + "start": 5535.71, + "duration": 4.5 + }, + { + "text": "to representing structures of things so", + "start": 5537.72, + "duration": 4.2 + }, + { + "text": "these values don't just need to be", + "start": 5540.21, + "duration": 4.38 + }, + { + "text": "strings or numbers they could be lists", + "start": 5541.92, + "duration": 4.44 + }, + { + "text": "or arrays that happen have a sequence of", + "start": 5544.59, + "duration": 3.96 + }, + { + "text": "possible values or they could even be", + "start": 5546.36, + "duration": 4.29 + }, + { + "text": "other javascript objects that if we", + "start": 5548.55, + "duration": 4.2 + }, + { + "text": "wanted to represent not just a city name", + "start": 5550.65, + "duration": 4.23 + }, + { + "text": "but represent the city name and the", + "start": 5552.75, + "duration": 4.02 + }, + { + "text": "airport code for example as we saw that", + "start": 5554.88, + "duration": 4.08 + }, + { + "text": "we wanted to do before I could instead", + "start": 5556.77, + "duration": 4.2 + }, + { + "text": "of having origin be equal to a string", + "start": 5558.96, + "duration": 4.56 + }, + { + "text": "like New York have origin be equal to", + "start": 5560.97, + "duration": 5.01 + }, + { + "text": "yet another JavaScript object that", + "start": 5563.52, + "duration": 4.89 + }, + { + "text": "contains a city property and a code", + "start": 5565.98, + "duration": 3.78 + }, + { + "text": "property where the city is the name of", + "start": 5568.41, + "duration": 3.57 + }, + { + "text": "the city and the code is the name of the", + "start": 5569.76, + "duration": 3.96 + }, + { + "text": "airport code and the important thing is", + "start": 5571.98, + "duration": 3.54 + }, + { + "text": "as long as I and the person I'm", + "start": 5573.72, + "duration": 3.66 + }, + { + "text": "communicating with agree upon this", + "start": 5575.52, + "duration": 3.99 + }, + { + "text": "representation agree upon what the names", + "start": 5577.38, + "duration": 4.11 + }, + { + "text": "of these keys are and what the structure", + "start": 5579.51, + "duration": 4.74 + }, + { + "text": "of this JSON payload this JSON object", + "start": 5581.49, + "duration": 5.04 + }, + { + "text": "happens to be then the person on the", + "start": 5584.25, + "duration": 4.2 + }, + { + "text": "receiving end can take this data and", + "start": 5586.53, + "duration": 3.6 + }, + { + "text": "write a program that's able to interpret", + "start": 5588.45, + "duration": 3.63 + }, + { + "text": "it and use that data in some meaningful", + "start": 5590.13, + "duration": 4.23 + }, + { + "text": "way and so we'll see an example of this", + "start": 5592.08, + "duration": 4.41 + }, + { + "text": "now of using javascript to be able to", + "start": 5594.36, + "duration": 3.51 + }, + { + "text": "communicate with yet another online", + "start": 5596.49, + "duration": 3.93 + }, + { + "text": "service in particular for accessing", + "start": 5597.87, + "duration": 4.8 + }, + { + "text": "information about currency exchange", + "start": 5600.42, + "duration": 3.78 + }, + { + "text": "rates currency exchange rates are always", + "start": 5602.67, + "duration": 3.36 + }, + { + "text": "changing we want access to the latest", + "start": 5604.2, + "duration": 4.2 + }, + { + "text": "currency exchange rate data and if there", + "start": 5606.03, + "duration": 4.32 + }, + { + "text": "is an online service an API that", + "start": 5608.4, + "duration": 4.14 + }, + { + "text": "provides access to that data in JSON", + "start": 5610.35, + "duration": 4.11 + }, + { + "text": "form in a format like this that is", + "start": 5612.54, + "duration": 3.87 + }, + { + "text": "machine readable then we can use that", + "start": 5614.46, + "duration": 4.77 + }, + { + "text": "data to write a stock a currency", + "start": 5616.41, + "duration": 5.16 + }, + { + "text": "exchange application that uses real time", + "start": 5619.23, + "duration": 2.88 + }, + { + "text": "data", + "start": 5621.57, + "duration": 2.79 + }, + { + "text": "in order to make those conversions what", + "start": 5622.11, + "duration": 3.839 + }, + { + "text": "might that data look like well the data", + "start": 5624.36, + "duration": 3.449 + }, + { + "text": "could look something like this that we", + "start": 5625.949, + "duration": 3.841 + }, + { + "text": "make a request for accessing what are", + "start": 5627.809, + "duration": 3.81 + }, + { + "text": "the exchange rates for converting from", + "start": 5629.79, + "duration": 4.17 + }, + { + "text": "US dollars of the West Newton is USD and", + "start": 5631.619, + "duration": 4.951 + }, + { + "text": "we get back a JSON object that looks", + "start": 5633.96, + "duration": 5.79 + }, + { + "text": "like this and it has a base key of USD", + "start": 5636.57, + "duration": 5.549 + }, + { + "text": "and then has a rates key that has a", + "start": 5639.75, + "duration": 3.659 + }, + { + "text": "whole bunch of rates within it so", + "start": 5642.119, + "duration": 2.881 + }, + { + "text": "conversion to euros and Japanese yen", + "start": 5643.409, + "duration": 4.051 + }, + { + "text": "great british britain pounds as well as", + "start": 5645.0, + "duration": 4.079 + }, + { + "text": "Australian dollars and all of the", + "start": 5647.46, + "duration": 3.06 + }, + { + "text": "various different currency exchange", + "start": 5649.079, + "duration": 2.58 + }, + { + "text": "rates for all of these different", + "start": 5650.52, + "duration": 3.659 + }, + { + "text": "currencies for example and this doesn't", + "start": 5651.659, + "duration": 4.351 + }, + { + "text": "have to be the way that this data is", + "start": 5654.179, + "duration": 3.121 + }, + { + "text": "structured but it happens to be a", + "start": 5656.01, + "duration": 3.33 + }, + { + "text": "convenient way and so long as the person", + "start": 5657.3, + "duration": 4.68 + }, + { + "text": "providing this data to me and I both", + "start": 5659.34, + "duration": 4.649 + }, + { + "text": "know what this structure is we can begin", + "start": 5661.98, + "duration": 3.929 + }, + { + "text": "to write programs that are able to use", + "start": 5663.989, + "duration": 3.9 + }, + { + "text": "that data and so will now see our", + "start": 5665.909, + "duration": 6.301 + }, + { + "text": "example of an API which is exchange", + "start": 5667.889, + "duration": 7.951 + }, + { + "text": "rates API I owe and if we go to API dot", + "start": 5672.21, + "duration": 6.21 + }, + { + "text": "exchange rates API am / latest and", + "start": 5675.84, + "duration": 5.069 + }, + { + "text": "provide a get parameter of base equals", + "start": 5678.42, + "duration": 6.09 + }, + { + "text": "US dollars then what we get back is data", + "start": 5680.909, + "duration": 4.851 + }, + { + "text": "that looks like this", + "start": 5684.51, + "duration": 3.45 + }, + { + "text": "now it's a little bit messy looking not", + "start": 5685.76, + "duration": 4.12 + }, + { + "text": "nearly as clean as we saw before but", + "start": 5687.96, + "duration": 3.63 + }, + { + "text": "it's the same exact thing just without", + "start": 5689.88, + "duration": 3.239 + }, + { + "text": "the whitespace we have a JavaScript", + "start": 5691.59, + "duration": 4.259 + }, + { + "text": "object that has a rates key that tells", + "start": 5693.119, + "duration": 4.891 + }, + { + "text": "me all right here is the exchange rate", + "start": 5695.849, + "duration": 4.801 + }, + { + "text": "between US Dollars and Canadian dollars", + "start": 5698.01, + "duration": 4.2 + }, + { + "text": "in the pound in the euro and other", + "start": 5700.65, + "duration": 3.839 + }, + { + "text": "currencies that exist as well and down", + "start": 5702.21, + "duration": 4.02 + }, + { + "text": "below we have the base of what base", + "start": 5704.489, + "duration": 4.17 + }, + { + "text": "currency we're converting from so all of", + "start": 5706.23, + "duration": 4.8 + }, + { + "text": "this data can come back to me if I just", + "start": 5708.659, + "duration": 4.381 + }, + { + "text": "make an HTTP request I make a web", + "start": 5711.03, + "duration": 4.919 + }, + { + "text": "request to this particular URL I then", + "start": 5713.04, + "duration": 5.22 + }, + { + "text": "get access to all of this currency", + "start": 5715.949, + "duration": 4.561 + }, + { + "text": "exchange rate information that I can", + "start": 5718.26, + "duration": 5.16 + }, + { + "text": "then use inside of my application so how", + "start": 5720.51, + "duration": 4.74 + }, + { + "text": "can I do this how can I now begin to use", + "start": 5723.42, + "duration": 4.17 + }, + { + "text": "this information inside of an", + "start": 5725.25, + "duration": 4.8 + }, + { + "text": "application let's now create a new page", + "start": 5727.59, + "duration": 7.109 + }, + { + "text": "I'm gonna call this currency HTML inside", + "start": 5730.05, + "duration": 9.359 + }, + { + "text": "of currency about HTML at our usual HTML", + "start": 5734.699, + "duration": 8.88 + }, + { + "text": "a title of currency exchange and a body", + "start": 5739.409, + "duration": 7.23 + }, + { + "text": "and inside the body and we're just going", + "start": 5743.579, + "duration": 4.921 + }, + { + "text": "to include nothing for now what I really", + "start": 5746.639, + "duration": 3.721 + }, + { + "text": "care about is the JavaScript that is", + "start": 5748.5, + "duration": 4.53 + }, + { + "text": "going to make a web request in order to", + "start": 5750.36, + "duration": 5.1 + }, + { + "text": "get access to additional data", + "start": 5753.03, + "duration": 4.83 + }, + { + "text": "so far in JavaScript our JavaScript code", + "start": 5755.46, + "duration": 4.77 + }, + { + "text": "has exclusively been running code that", + "start": 5757.86, + "duration": 5.28 + }, + { + "text": "exists only on our computer it's running", + "start": 5760.23, + "duration": 4.739 + }, + { + "text": "inside the web browser and all happening", + "start": 5763.14, + "duration": 3.21 + }, + { + "text": "inside the web browser we're not", + "start": 5764.969, + "duration": 2.941 + }, + { + "text": "communicating with some external server", + "start": 5766.35, + "duration": 3.33 + }, + { + "text": "what we'll take a look at now is", + "start": 5767.91, + "duration": 3.75 + }, + { + "text": "something known as Ajax which was about", + "start": 5769.68, + "duration": 3.87 + }, + { + "text": "asynchronous JavaScript where the idea", + "start": 5771.66, + "duration": 4.02 + }, + { + "text": "is that even after a page has loaded", + "start": 5773.55, + "duration": 5.189 + }, + { + "text": "using JavaScript we can make additional", + "start": 5775.68, + "duration": 4.92 + }, + { + "text": "web requests to ask for additional", + "start": 5778.739, + "duration": 4.051 + }, + { + "text": "information either from our own web", + "start": 5780.6, + "duration": 3.9 + }, + { + "text": "servers or from some third party web", + "start": 5782.79, + "duration": 3.69 + }, + { + "text": "servers if we want additional", + "start": 5784.5, + "duration": 4.41 + }, + { + "text": "information on our page and what we want", + "start": 5786.48, + "duration": 4.41 + }, + { + "text": "in this case is for our page to make an", + "start": 5788.91, + "duration": 4.26 + }, + { + "text": "asynchronous request to request for", + "start": 5790.89, + "duration": 4.71 + }, + { + "text": "additional data about the current", + "start": 5793.17, + "duration": 5.88 + }, + { + "text": "currency exchange rates for example so", + "start": 5795.6, + "duration": 5.25 + }, + { + "text": "how am I going to do that well I want to", + "start": 5799.05, + "duration": 6.86 + }, + { + "text": "do this after the Dom content is loaded", + "start": 5800.85, + "duration": 8.639 + }, + { + "text": "so we'll add that usually there and what", + "start": 5805.91, + "duration": 4.75 + }, + { + "text": "we're going to take advantage of as a", + "start": 5809.489, + "duration": 2.521 + }, + { + "text": "function built-in to more recent", + "start": 5810.66, + "duration": 2.82 + }, + { + "text": "versions of JavaScript and supported by", + "start": 5812.01, + "duration": 3.45 + }, + { + "text": "most major browsers now and if the", + "start": 5813.48, + "duration": 4.56 + }, + { + "text": "function called fetch and what fetch is", + "start": 5815.46, + "duration": 4.56 + }, + { + "text": "going to do is it is going to make a web", + "start": 5818.04, + "duration": 4.02 + }, + { + "text": "request it is going to query some", + "start": 5820.02, + "duration": 3.48 + }, + { + "text": "website it could be our own it could be", + "start": 5822.06, + "duration": 3.36 + }, + { + "text": "someone else's and it's gonna get back", + "start": 5823.5, + "duration": 5.13 + }, + { + "text": "some HTTP response from that page and", + "start": 5825.42, + "duration": 5.28 + }, + { + "text": "I'm going to fetch in the page I'm going", + "start": 5828.63, + "duration": 6.03 + }, + { + "text": "to fetch is this URL API not exchange", + "start": 5830.7, + "duration": 6.57 + }, + { + "text": "rates API dot io / latest base equals", + "start": 5834.66, + "duration": 4.68 + }, + { + "text": "USD and the only reason I happen to know", + "start": 5837.27, + "duration": 3.78 + }, + { + "text": "how this API works is because I've read", + "start": 5839.34, + "duration": 3.93 + }, + { + "text": "the api's documentation that describes", + "start": 5841.05, + "duration": 4.59 + }, + { + "text": "how the URL parameters work and what the", + "start": 5843.27, + "duration": 3.66 + }, + { + "text": "structure of the data that I get back", + "start": 5845.64, + "duration": 4.17 + }, + { + "text": "isn't and so I'm here going to say go", + "start": 5846.93, + "duration": 5.16 + }, + { + "text": "ahead and fetch from this URL make a", + "start": 5849.81, + "duration": 4.62 + }, + { + "text": "HTTP request asking for additional", + "start": 5852.09, + "duration": 5.43 + }, + { + "text": "information from this URL and get back", + "start": 5854.43, + "duration": 4.95 + }, + { + "text": "what the results are going to be and", + "start": 5857.52, + "duration": 4.68 + }, + { + "text": "what fetch gives back to us is something", + "start": 5859.38, + "duration": 5.28 + }, + { + "text": "in JavaScript known as a promise and a", + "start": 5862.2, + "duration": 3.96 + }, + { + "text": "promise is going to be a way of", + "start": 5864.66, + "duration": 3.96 + }, + { + "text": "representing the idea that something is", + "start": 5866.16, + "duration": 4.2 + }, + { + "text": "going to come back but it may not come", + "start": 5868.62, + "duration": 3.69 + }, + { + "text": "back immediately we're not going to go", + "start": 5870.36, + "duration": 3.33 + }, + { + "text": "into the details of exactly how those", + "start": 5872.31, + "duration": 3.15 + }, + { + "text": "promises work but it turns out there's a", + "start": 5873.69, + "duration": 3.45 + }, + { + "text": "particular syntax for dealing with them", + "start": 5875.46, + "duration": 4.14 + }, + { + "text": "which is that I can say after I fetch I", + "start": 5877.14, + "duration": 6.45 + }, + { + "text": "can add a line called dot then that says", + "start": 5879.6, + "duration": 5.85 + }, + { + "text": "what should I do when the promise comes", + "start": 5883.59, + "duration": 4.26 + }, + { + "text": "back once I get back something like a", + "start": 5885.45, + "duration": 3.84 + }, + { + "text": "response", + "start": 5887.85, + "duration": 3.39 + }, + { + "text": "and so when I get back the response what", + "start": 5889.29, + "duration": 3.93 + }, + { + "text": "I want to do is convert the response", + "start": 5891.24, + "duration": 5.22 + }, + { + "text": "into Jason treat it as Jason data Java a", + "start": 5893.22, + "duration": 5.19 + }, + { + "text": "JavaScript object as something that I", + "start": 5896.46, + "duration": 3.96 + }, + { + "text": "can then manipulate and so what I can do", + "start": 5898.41, + "duration": 4.32 + }, + { + "text": "is just use this as a function to say go", + "start": 5900.42, + "duration": 8.04 + }, + { + "text": "ahead and return response Jason and so", + "start": 5902.73, + "duration": 7.68 + }, + { + "text": "what this is saying is go ahead and get", + "start": 5908.46, + "duration": 4.5 + }, + { + "text": "me the latest exchange rates and then", + "start": 5910.41, + "duration": 4.2 + }, + { + "text": "after that's done this is an", + "start": 5912.96, + "duration": 3.18 + }, + { + "text": "asynchronous process it might take some", + "start": 5914.61, + "duration": 3.78 + }, + { + "text": "time but once I get back those results", + "start": 5916.14, + "duration": 4.89 + }, + { + "text": "then run this function take the response", + "start": 5918.39, + "duration": 5.52 + }, + { + "text": "and return the jason version of the", + "start": 5921.03, + "duration": 4.98 + }, + { + "text": "response convert that response into just", + "start": 5923.91, + "duration": 4.5 + }, + { + "text": "the raw JSON data such that I can use", + "start": 5926.01, + "duration": 4.32 + }, + { + "text": "that data to then access the currency", + "start": 5928.41, + "duration": 3.96 + }, + { + "text": "exchange rates and it turns out that", + "start": 5930.33, + "duration": 3.81 + }, + { + "text": "with arrow functions if you ever have a", + "start": 5932.37, + "duration": 3.42 + }, + { + "text": "very simple function that all it's doing", + "start": 5934.14, + "duration": 3.57 + }, + { + "text": "is taking something and returning", + "start": 5935.79, + "duration": 4.17 + }, + { + "text": "something else I can simplify this", + "start": 5937.71, + "duration": 4.86 + }, + { + "text": "function even further and just say I can", + "start": 5939.96, + "duration": 4.05 + }, + { + "text": "omit the curly braces I can omit the", + "start": 5942.57, + "duration": 2.01 + }, + { + "text": "return", + "start": 5944.01, + "duration": 3.36 + }, + { + "text": "I can just say response arrow response", + "start": 5944.58, + "duration": 4.86 + }, + { + "text": "Jason and this is a shorthand way of", + "start": 5947.37, + "duration": 4.38 + }, + { + "text": "saying a function that takes as input", + "start": 5949.44, + "duration": 4.44 + }, + { + "text": "the response and returns as output", + "start": 5951.75, + "duration": 5.7 + }, + { + "text": "response to Jason so here I'm saying go", + "start": 5953.88, + "duration": 5.1 + }, + { + "text": "ahead and fetch me in the latest", + "start": 5957.45, + "duration": 3.71 + }, + { + "text": "exchange rates from this particular API", + "start": 5958.98, + "duration": 4.83 + }, + { + "text": "then convert the response to Jason data", + "start": 5961.16, + "duration": 6.88 + }, + { + "text": "and then once you have the data here's", + "start": 5963.81, + "duration": 6.9 + }, + { + "text": "what I want you to do with that data and", + "start": 5968.04, + "duration": 4.65 + }, + { + "text": "for now let's just go ahead and console", + "start": 5970.71, + "duration": 4.38 + }, + { + "text": "dot log that data just to print it out", + "start": 5972.69, + "duration": 4.08 + }, + { + "text": "to the terminal so we're not doing", + "start": 5975.09, + "duration": 3.12 + }, + { + "text": "anything else to us yet all I'm doing is", + "start": 5976.77, + "duration": 3.93 + }, + { + "text": "saying get me the exchange rates convert", + "start": 5978.21, + "duration": 4.32 + }, + { + "text": "the exchange rates data into Jason and", + "start": 5980.7, + "duration": 4.41 + }, + { + "text": "then let's go ahead and print out that", + "start": 5982.53, + "duration": 6.45 + }, + { + "text": "data so I'll open up currency at HTML", + "start": 5985.11, + "duration": 6.48 + }, + { + "text": "it's a blank page but if I look in the", + "start": 5988.98, + "duration": 4.8 + }, + { + "text": "JavaScript inspector I see what got", + "start": 5991.59, + "duration": 4.35 + }, + { + "text": "logged is a JavaScript object here", + "start": 5993.78, + "duration": 4.2 + }, + { + "text": "indicated by the word object and if I", + "start": 5995.94, + "duration": 4.35 + }, + { + "text": "click the triangle at left I can open up", + "start": 5997.98, + "duration": 4.02 + }, + { + "text": "and see all right inside of this object", + "start": 6000.29, + "duration": 5.75 + }, + { + "text": "is all of this data about exchange rates", + "start": 6002.0, + "duration": 6.09 + }, + { + "text": "for a whole bunch of different exchange", + "start": 6006.04, + "duration": 3.61 + }, + { + "text": "rates for converting from the US dollar", + "start": 6008.09, + "duration": 3.45 + }, + { + "text": "we're here u.s. dollar one means one", + "start": 6009.65, + "duration": 3.81 + }, + { + "text": "u.s. dollar is one u.s. dollar for", + "start": 6011.54, + "duration": 5.01 + }, + { + "text": "example so now that I've got this data", + "start": 6013.46, + "duration": 5.73 + }, + { + "text": "let's actually try and use this inside", + "start": 6016.55, + "duration": 4.14 + }, + { + "text": "of the program maybe let's say I want to", + "start": 6019.19, + "duration": 3.87 + }, + { + "text": "convert between US Dollars and the", + "start": 6020.69, + "duration": 3.54 + }, + { + "text": "to figure out what the conversion rate", + "start": 6023.06, + "duration": 3.63 + }, + { + "text": "is between dollars and euros well if we", + "start": 6024.23, + "duration": 4.68 + }, + { + "text": "recall what the data looks like the data", + "start": 6026.69, + "duration": 5.82 + }, + { + "text": "is a JavaScript object where we have a", + "start": 6028.91, + "duration": 7.08 + }, + { + "text": "key called rate and inside of rates is", + "start": 6032.51, + "duration": 5.94 + }, + { + "text": "this object and inside of that object I", + "start": 6035.99, + "duration": 5.43 + }, + { + "text": "can access the EU our property to get", + "start": 6038.45, + "duration": 4.77 + }, + { + "text": "the exchange rate of one US dollar is", + "start": 6041.42, + "duration": 3.72 + }, + { + "text": "equal to some number of euros for", + "start": 6043.22, + "duration": 4.05 + }, + { + "text": "example so it's inside of the rates key", + "start": 6045.14, + "duration": 4.83 + }, + { + "text": "and then inside of the EU our key and", + "start": 6047.27, + "duration": 5.22 + }, + { + "text": "that's how I know what to get access to", + "start": 6049.97, + "duration": 6.48 + }, + { + "text": "inside of my data so what I really want", + "start": 6052.49, + "duration": 10.11 + }, + { + "text": "to do is access data dot rates dot EU R", + "start": 6056.45, + "duration": 8.04 + }, + { + "text": "it says get me to all the data that came", + "start": 6062.6, + "duration": 4.95 + }, + { + "text": "back access the rates key and then", + "start": 6064.49, + "duration": 5.67 + }, + { + "text": "access the euro key and we'll go ahead", + "start": 6067.55, + "duration": 4.92 + }, + { + "text": "and save that in a variable called rate", + "start": 6070.16, + "duration": 6.69 + }, + { + "text": "and now I'll just document query", + "start": 6072.47, + "duration": 7.08 + }, + { + "text": "selector body dot innerhtml", + "start": 6076.85, + "duration": 5.4 + }, + { + "text": "equals rate just like take that rate put", + "start": 6079.55, + "duration": 5.64 + }, + { + "text": "it inside of the body so now if i", + "start": 6082.25, + "duration": 6.03 + }, + { + "text": "refresh currency dot HTML what I see is", + "start": 6085.19, + "duration": 5.7 + }, + { + "text": "just this value 0.9 zero eight eight", + "start": 6088.28, + "duration": 3.99 + }, + { + "text": "four three which means that right now", + "start": 6090.89, + "duration": 3.51 + }, + { + "text": "one u.s. dollar happens to be equal to", + "start": 6092.27, + "duration": 4.32 + }, + { + "text": "about zero point nine one euros for", + "start": 6094.4, + "duration": 5.16 + }, + { + "text": "instance so that's useful I could make", + "start": 6096.59, + "duration": 4.68 + }, + { + "text": "this a little more human-friendly by", + "start": 6099.56, + "duration": 3.6 + }, + { + "text": "putting this inside of a template string", + "start": 6101.27, + "duration": 5.13 + }, + { + "text": "I could say one US dollar is equal to", + "start": 6103.16, + "duration": 8.37 + }, + { + "text": "and then rate euros for example and so", + "start": 6106.4, + "duration": 8.13 + }, + { + "text": "now if i refresh the page I see one u.s.", + "start": 6111.53, + "duration": 5.64 + }, + { + "text": "dollar is equal to this many euros and", + "start": 6114.53, + "duration": 4.38 + }, + { + "text": "even this is a little bit annoying I", + "start": 6117.17, + "duration": 2.91 + }, + { + "text": "probably don't care about it too this", + "start": 6118.91, + "duration": 3.18 + }, + { + "text": "many decimal places and some really in", + "start": 6120.08, + "duration": 3.63 + }, + { + "text": "the mood to be very precise about these", + "start": 6122.09, + "duration": 3.51 + }, + { + "text": "exchange rates if I only care about it", + "start": 6123.71, + "duration": 4.14 + }, + { + "text": "to like 3 decimal places for example it", + "start": 6125.6, + "duration": 4.17 + }, + { + "text": "turns out JavaScript has functions I can", + "start": 6127.85, + "duration": 4.73 + }, + { + "text": "use on numbers like rate dot two fixed", + "start": 6129.77, + "duration": 5.76 + }, + { + "text": "passing in three as an argument there to", + "start": 6132.58, + "duration": 4.39 + }, + { + "text": "mean I'd like to take this exchange rate", + "start": 6135.53, + "duration": 3.6 + }, + { + "text": "and just round it to three decimal", + "start": 6136.97, + "duration": 4.8 + }, + { + "text": "places for example so now i refresh the", + "start": 6139.13, + "duration": 5.16 + }, + { + "text": "page and I see one u.s. dollar is equal", + "start": 6141.77, + "duration": 4.86 + }, + { + "text": "to zero point nine zero nine euros and", + "start": 6144.29, + "duration": 3.45 + }, + { + "text": "the interesting thing about what's", + "start": 6146.63, + "duration": 3.0 + }, + { + "text": "happening here is this is happening as a", + "start": 6147.74, + "duration": 4.29 + }, + { + "text": "result of an asynchronous request I am", + "start": 6149.63, + "duration": 4.89 + }, + { + "text": "asking for the latest exchange rates and", + "start": 6152.03, + "duration": 4.619 + }, + { + "text": "when I get back the exchange rates date", + "start": 6154.52, + "duration": 4.229 + }, + { + "text": "javascript is plugging that information", + "start": 6156.649, + "duration": 3.99 + }, + { + "text": "into the body of the page I now", + "start": 6158.749, + "duration": 4.321 + }, + { + "text": "communicating with an API getting back", + "start": 6160.639, + "duration": 5.01 + }, + { + "text": "that api's data in JSON form and then", + "start": 6163.07, + "duration": 5.25 + }, + { + "text": "using that data to update the contents", + "start": 6165.649, + "duration": 6.09 + }, + { + "text": "of my HTML page of course in practice if", + "start": 6168.32, + "duration": 5.369 + }, + { + "text": "I really want a currency exchange web", + "start": 6171.739, + "duration": 3.66 + }, + { + "text": "page I probably don't just want to", + "start": 6173.689, + "duration": 3.3 + }, + { + "text": "display the exchange rate between US", + "start": 6175.399, + "duration": 3.691 + }, + { + "text": "dollars and euros I probably want to let", + "start": 6176.989, + "duration": 4.621 + }, + { + "text": "the user pick what currencies they would", + "start": 6179.09, + "duration": 4.649 + }, + { + "text": "like to exchange between and so here's", + "start": 6181.61, + "duration": 5.94 + }, + { + "text": "how I might go about doing that inside", + "start": 6183.739, + "duration": 5.82 + }, + { + "text": "of the body of the page now rather than", + "start": 6187.55, + "duration": 3.899 + }, + { + "text": "just have an empty body let's go ahead", + "start": 6189.559, + "duration": 4.02 + }, + { + "text": "and add a form that form is going to", + "start": 6191.449, + "duration": 4.411 + }, + { + "text": "have an input whose ID is currency just", + "start": 6193.579, + "duration": 3.63 + }, + { + "text": "so I have a way of referencing it later", + "start": 6195.86, + "duration": 3.629 + }, + { + "text": "the place holder will just be currency", + "start": 6197.209, + "duration": 5.64 + }, + { + "text": "and the type of it is text and then I'll", + "start": 6199.489, + "duration": 5.7 + }, + { + "text": "have an input whose type is submit and", + "start": 6202.849, + "duration": 4.681 + }, + { + "text": "we'll give it a value of convert that'll", + "start": 6205.189, + "duration": 3.69 + }, + { + "text": "be what the button says it says convert", + "start": 6207.53, + "duration": 3.27 + }, + { + "text": "and then I can convert to a particular", + "start": 6208.879, + "duration": 4.68 + }, + { + "text": "currency and then I need some place to", + "start": 6210.8, + "duration": 5.129 + }, + { + "text": "put my results so I'll go ahead and add", + "start": 6213.559, + "duration": 5.82 + }, + { + "text": "a div whose ID is result and this is", + "start": 6215.929, + "duration": 4.98 + }, + { + "text": "where after I've done all the currency", + "start": 6219.379, + "duration": 3.211 + }, + { + "text": "conversion this is where I'm going to", + "start": 6220.909, + "duration": 3.48 + }, + { + "text": "put the results of doing that currency", + "start": 6222.59, + "duration": 5.67 + }, + { + "text": "conversion so now rather than fetch", + "start": 6224.389, + "duration": 5.46 + }, + { + "text": "right away here's what I need to do I", + "start": 6228.26, + "duration": 4.109 + }, + { + "text": "need to do something only when the form", + "start": 6229.849, + "duration": 3.241 + }, + { + "text": "is submitted", + "start": 6232.369, + "duration": 3.661 + }, + { + "text": "so I can get the form by saying document", + "start": 6233.09, + "duration": 6.989 + }, + { + "text": "query selector form dot on submit equals", + "start": 6236.03, + "duration": 6.359 + }, + { + "text": "this function and I'm gonna go ahead and", + "start": 6240.079, + "duration": 4.62 + }, + { + "text": "just in advance return false at the end", + "start": 6242.389, + "duration": 4.23 + }, + { + "text": "of the function so we don't actually try", + "start": 6244.699, + "duration": 3.54 + }, + { + "text": "and submit the form to another page I", + "start": 6246.619, + "duration": 3.33 + }, + { + "text": "just want to run everything locally on", + "start": 6248.239, + "duration": 5.101 + }, + { + "text": "this same page but now inside of this", + "start": 6249.949, + "duration": 6.42 + }, + { + "text": "form once you submit it that is when I", + "start": 6253.34, + "duration": 5.159 + }, + { + "text": "want to run this code that is going to", + "start": 6256.369, + "duration": 4.56 + }, + { + "text": "fetch new data so I'm going to fetch", + "start": 6258.499, + "duration": 5.16 + }, + { + "text": "data from the exchange rates API convert", + "start": 6260.929, + "duration": 5.04 + }, + { + "text": "that data to Jason same as before then", + "start": 6263.659, + "duration": 4.621 + }, + { + "text": "go ahead and get access to that data but", + "start": 6265.969, + "duration": 4.351 + }, + { + "text": "now what I want to do is I want to", + "start": 6268.28, + "duration": 4.919 + }, + { + "text": "figure out what the user actually typed", + "start": 6270.32, + "duration": 4.98 + }, + { + "text": "in to the input field and that is going", + "start": 6273.199, + "duration": 3.3 + }, + { + "text": "to be the currency that I care about", + "start": 6275.3, + "duration": 2.909 + }, + { + "text": "getting access to so I'll create a", + "start": 6276.499, + "duration": 3.93 + }, + { + "text": "variable called currency which will be", + "start": 6278.209, + "duration": 5.46 + }, + { + "text": "equal to document query selector and I", + "start": 6280.429, + "duration": 4.77 + }, + { + "text": "write the input field if I scroll down", + "start": 6283.669, + "duration": 4.62 + }, + { + "text": "it has an ID of currency so if I want to", + "start": 6285.199, + "duration": 4.811 + }, + { + "text": "get that input field I'm", + "start": 6288.289, + "duration": 4.541 + }, + { + "text": "to say get the element whose ID is", + "start": 6290.01, + "duration": 7.08 + }, + { + "text": "currency and get its value so this now", + "start": 6292.83, + "duration": 7.35 + }, + { + "text": "is the currency that the user wanted me", + "start": 6297.09, + "duration": 7.05 + }, + { + "text": "to get access to and I can then say data", + "start": 6300.18, + "duration": 9.15 + }, + { + "text": "rates currency instead of data rates dot", + "start": 6304.14, + "duration": 7.11 + }, + { + "text": "you are and importantly I can't do data", + "start": 6309.33, + "duration": 4.29 + }, + { + "text": "rates dot currency that would literally", + "start": 6311.25, + "duration": 4.11 + }, + { + "text": "try to access a property of rates that", + "start": 6313.62, + "duration": 4.11 + }, + { + "text": "is called currency if I use square", + "start": 6315.36, + "duration": 4.5 + }, + { + "text": "brackets instead that allows me to use a", + "start": 6317.73, + "duration": 3.96 + }, + { + "text": "variable something like the currency", + "start": 6319.86, + "duration": 3.54 + }, + { + "text": "variable which are defined up here on", + "start": 6321.69, + "duration": 4.29 + }, + { + "text": "line 13 as the currency that the user", + "start": 6323.4, + "duration": 4.59 + }, + { + "text": "typed in I would like to access that", + "start": 6325.98, + "duration": 4.7 + }, + { + "text": "particular currency inside of the rates", + "start": 6327.99, + "duration": 6.03 + }, + { + "text": "and so now I can ask a question there", + "start": 6330.68, + "duration": 5.11 + }, + { + "text": "are two possibilities here either the", + "start": 6334.02, + "duration": 4.11 + }, + { + "text": "currency the user typed in it is a valid", + "start": 6335.79, + "duration": 5.28 + }, + { + "text": "currency or it's not and it turns out", + "start": 6338.13, + "duration": 5.13 + }, + { + "text": "that if you try and access a property of", + "start": 6341.07, + "duration": 4.32 + }, + { + "text": "an object that doesn't exist what you", + "start": 6343.26, + "duration": 3.42 + }, + { + "text": "get back is a particular JavaScript", + "start": 6345.39, + "duration": 3.66 + }, + { + "text": "variable called undefined meaning there", + "start": 6346.68, + "duration": 5.04 + }, + { + "text": "is no value there so for example if I", + "start": 6349.05, + "duration": 5.61 + }, + { + "text": "have something like let person equal", + "start": 6351.72, + "duration": 5.82 + }, + { + "text": "first name is Harry and last name is", + "start": 6354.66, + "duration": 5.61 + }, + { + "text": "Potter like we did before I can access", + "start": 6357.54, + "duration": 5.04 + }, + { + "text": "something like person dot first and get", + "start": 6360.27, + "duration": 4.71 + }, + { + "text": "Harry I can access person dot last and", + "start": 6362.58, + "duration": 4.47 + }, + { + "text": "get Potter but if I access person dot", + "start": 6364.98, + "duration": 4.08 + }, + { + "text": "middle that is going to be a special", + "start": 6367.05, + "duration": 3.99 + }, + { + "text": "variable in JavaScript or a special", + "start": 6369.06, + "duration": 3.99 + }, + { + "text": "value in JavaScript called undefined", + "start": 6371.04, + "duration": 5.31 + }, + { + "text": "meaning there is no value there it's", + "start": 6373.05, + "duration": 4.77 + }, + { + "text": "slightly different from null which also", + "start": 6376.35, + "duration": 3.12 + }, + { + "text": "has a similar meaning they're used in", + "start": 6377.82, + "duration": 3.78 + }, + { + "text": "slightly different contexts so here what", + "start": 6379.47, + "duration": 5.06 + }, + { + "text": "I can say is if the rate is not", + "start": 6381.6, + "duration": 7.05 + }, + { + "text": "undefined well then let's go ahead and", + "start": 6384.53, + "duration": 10.96 + }, + { + "text": "update not the body but the result to", + "start": 6388.65, + "duration": 10.05 + }, + { + "text": "say one u.s. dollar is equal to this", + "start": 6395.49, + "duration": 6.96 + }, + { + "text": "rate not necessarily euros but whatever", + "start": 6398.7, + "duration": 7.85 + }, + { + "text": "the currency happens to be and otherwise", + "start": 6402.45, + "duration": 6.51 + }, + { + "text": "let's go ahead and document query", + "start": 6406.55, + "duration": 6.81 + }, + { + "text": "selector result dot inner HTML equals", + "start": 6408.96, + "duration": 7.44 + }, + { + "text": "invalid currency just to let the user", + "start": 6413.36, + "duration": 4.6 + }, + { + "text": "know that the currency they tried to", + "start": 6416.4, + "duration": 3.87 + }, + { + "text": "provide is not actually a valid currency", + "start": 6417.96, + "duration": 4.08 + }, + { + "text": "and so we're going to need to try a", + "start": 6420.27, + "duration": 3.28 + }, + { + "text": "different currency in order to get the", + "start": 6422.04, + "duration": 4.3 + }, + { + "text": "all to work so now here's what we can do", + "start": 6423.55, + "duration": 5.58 + }, + { + "text": "if I open up currency dot HTML again I", + "start": 6426.34, + "duration": 5.219 + }, + { + "text": "now see a form where I can type in a", + "start": 6429.13, + "duration": 4.259 + }, + { + "text": "currency I can type in something like", + "start": 6431.559, + "duration": 4.35 + }, + { + "text": "the Europe for example press convert and", + "start": 6433.389, + "duration": 4.381 + }, + { + "text": "I see alright one u.s. dollar equal to", + "start": 6435.909, + "duration": 5.58 + }, + { + "text": "0.9 0.0 something like the pound press", + "start": 6437.77, + "duration": 6.03 + }, + { + "text": "convert one u.s. dollar equal to 0.77", + "start": 6441.489, + "duration": 4.98 + }, + { + "text": "one pounds I type in the Japanese yen", + "start": 6443.8, + "duration": 4.859 + }, + { + "text": "one u.s. dollar is equal to 109 point", + "start": 6446.469, + "duration": 4.351 + }, + { + "text": "eight five two Japanese yen and all of", + "start": 6448.659, + "duration": 3.54 + }, + { + "text": "this is happening where every time I", + "start": 6450.82, + "duration": 3.21 + }, + { + "text": "submit the form it's making yet another", + "start": 6452.199, + "duration": 4.261 + }, + { + "text": "request so if the exchange rates happen", + "start": 6454.03, + "duration": 3.99 + }, + { + "text": "to change in between when I submit the", + "start": 6456.46, + "duration": 3.599 + }, + { + "text": "form the next time I submit the form I", + "start": 6458.02, + "duration": 3.51 + }, + { + "text": "will be getting the latest exchange", + "start": 6460.059, + "duration": 3.361 + }, + { + "text": "rates according to that exchange rates", + "start": 6461.53, + "duration": 4.08 + }, + { + "text": "API and the results are going to come", + "start": 6463.42, + "duration": 3.989 + }, + { + "text": "back here and of course if I type in a", + "start": 6465.61, + "duration": 3.719 + }, + { + "text": "currency that doesn't exist I type in", + "start": 6467.409, + "duration": 3.81 + }, + { + "text": "something like foo for example and press", + "start": 6469.329, + "duration": 4.261 + }, + { + "text": "convert invalid currency so it's going", + "start": 6471.219, + "duration": 4.051 + }, + { + "text": "to report back to me that it wasn't able", + "start": 6473.59, + "duration": 3.569 + }, + { + "text": "to find that currency and so it tells me", + "start": 6475.27, + "duration": 3.21 + }, + { + "text": "that I need to type in something valid", + "start": 6477.159, + "duration": 2.94 + }, + { + "text": "and so I can type in something valid", + "start": 6478.48, + "duration": 3.84 + }, + { + "text": "maybe I try just US dollars itself it", + "start": 6480.099, + "duration": 5.011 + }, + { + "text": "tells me one u.s. dollar is equal to one", + "start": 6482.32, + "duration": 4.68 + }, + { + "text": "US dollar exactly what I would expect it", + "start": 6485.11, + "duration": 4.469 + }, + { + "text": "to be now there are a couple of", + "start": 6487.0, + "duration": 4.11 + }, + { + "text": "optimizations and improvements that we", + "start": 6489.579, + "duration": 3.421 + }, + { + "text": "can make here one is that I can search", + "start": 6491.11, + "duration": 3.81 + }, + { + "text": "for euros right now with EU our press", + "start": 6493.0, + "duration": 4.05 + }, + { + "text": "convert but if I search for euros in", + "start": 6494.92, + "duration": 4.71 + }, + { + "text": "lower case for example it turns out it", + "start": 6497.05, + "duration": 4.2 + }, + { + "text": "thinks that's an invalid currency and", + "start": 6499.63, + "duration": 4.77 + }, + { + "text": "the reason why is because if you look at", + "start": 6501.25, + "duration": 4.8 + }, + { + "text": "the data that comes back to me from the", + "start": 6504.4, + "duration": 3.36 + }, + { + "text": "API this is the data that I get back", + "start": 6506.05, + "duration": 4.109 + }, + { + "text": "from the exchange rates API what you'll", + "start": 6507.76, + "duration": 4.319 + }, + { + "text": "notice is that all of the currencies are", + "start": 6510.159, + "duration": 3.841 + }, + { + "text": "all in capital letters that are all", + "start": 6512.079, + "duration": 3.451 + }, + { + "text": "capital letters all capital letters", + "start": 6514.0, + "duration": 3.599 + }, + { + "text": "which means the only keys that I'm", + "start": 6515.53, + "duration": 4.379 + }, + { + "text": "allowed to access are in fact those that", + "start": 6517.599, + "duration": 3.691 + }, + { + "text": "have capital letters in them because", + "start": 6519.909, + "duration": 3.21 + }, + { + "text": "these are the only keys that this API", + "start": 6521.29, + "duration": 4.53 + }, + { + "text": "makes available to me so if I want to", + "start": 6523.119, + "duration": 4.921 + }, + { + "text": "convert between US dollars and euros", + "start": 6525.82, + "duration": 4.589 + }, + { + "text": "lowercase what I might want to do is", + "start": 6528.04, + "duration": 4.92 + }, + { + "text": "first take the currency the thing the", + "start": 6530.409, + "duration": 6.54 + }, + { + "text": "user typed in and first just call to", + "start": 6532.96, + "duration": 6.0 + }, + { + "text": "uppercase on it which is a JavaScript", + "start": 6536.949, + "duration": 3.42 + }, + { + "text": "function that takes a string and", + "start": 6538.96, + "duration": 3.449 + }, + { + "text": "converts it Dabra case I'd like to take", + "start": 6540.369, + "duration": 3.931 + }, + { + "text": "whatever the user typed in and now just", + "start": 6542.409, + "duration": 3.931 + }, + { + "text": "first convert it to uppercase that way", + "start": 6544.3, + "duration": 4.77 + }, + { + "text": "if I go back here I can type in Euro", + "start": 6546.34, + "duration": 5.219 + }, + { + "text": "lowercase press convert and I'm still", + "start": 6549.07, + "duration": 4.94 + }, + { + "text": "able to get the correct conversion rate", + "start": 6551.559, + "duration": 4.861 + }, + { + "text": "the other thing that we won't noticeably", + "start": 6554.01, + "duration": 3.34 + }, + { + "text": "notice the difference with", + "start": 6556.42, + "duration": 3.6 + }, + { + "text": "is that right now I'm assuming that all", + "start": 6557.35, + "duration": 4.56 + }, + { + "text": "of this is going to go successfully that", + "start": 6560.02, + "duration": 3.3 + }, + { + "text": "we're gonna successfully be able to make", + "start": 6561.91, + "duration": 3.3 + }, + { + "text": "a web request will successfully convert", + "start": 6563.32, + "duration": 3.72 + }, + { + "text": "the response back to Jason but you never", + "start": 6565.21, + "duration": 3.93 + }, + { + "text": "know an API could go down the API could", + "start": 6567.04, + "duration": 3.84 + }, + { + "text": "change and do something unexpected and", + "start": 6569.14, + "duration": 3.42 + }, + { + "text": "so anytime you're dealing with these", + "start": 6570.88, + "duration": 3.15 + }, + { + "text": "types of promises where you fetch", + "start": 6572.56, + "duration": 3.45 + }, + { + "text": "something and say then do this then do", + "start": 6574.03, + "duration": 4.53 + }, + { + "text": "that it can often be a good idea to add", + "start": 6576.01, + "duration": 6.24 + }, + { + "text": "one last case which is a catch case that", + "start": 6578.56, + "duration": 5.34 + }, + { + "text": "basically says what should you do if", + "start": 6582.25, + "duration": 4.11 + }, + { + "text": "something goes wrong so I can say catch", + "start": 6583.9, + "duration": 4.2 + }, + { + "text": "the error and what I can just do is say", + "start": 6586.36, + "duration": 6.3 + }, + { + "text": "like console dot log error and then log", + "start": 6588.1, + "duration": 6.18 + }, + { + "text": "the error there and all that's really", + "start": 6592.66, + "duration": 3.87 + }, + { + "text": "saying is that if anything above goes", + "start": 6594.28, + "duration": 3.96 + }, + { + "text": "wrong with the fetching and trying to", + "start": 6596.53, + "duration": 3.72 + }, + { + "text": "process the response it's gonna catch", + "start": 6598.24, + "duration": 4.17 + }, + { + "text": "the error and then we'll just like print", + "start": 6600.25, + "duration": 3.96 + }, + { + "text": "out to the console that something went", + "start": 6602.41, + "duration": 3.72 + }, + { + "text": "wrong some error message happened and so", + "start": 6604.21, + "duration": 3.72 + }, + { + "text": "that can be a helpful nice to have just", + "start": 6606.13, + "duration": 3.39 + }, + { + "text": "to make sure that when things crash they", + "start": 6607.93, + "duration": 3.09 + }, + { + "text": "crash in a predictable way that you're", + "start": 6609.52, + "duration": 3.45 + }, + { + "text": "able to see exactly what the error is", + "start": 6611.02, + "duration": 4.44 + }, + { + "text": "and just by looking inside the", + "start": 6612.97, + "duration": 4.68 + }, + { + "text": "JavaScript console and so now we have a", + "start": 6615.46, + "duration": 4.5 + }, + { + "text": "fully working web page that is able to", + "start": 6617.65, + "duration": 4.71 + }, + { + "text": "communicate with an external API that is", + "start": 6619.96, + "duration": 4.53 + }, + { + "text": "able to ask for information from another", + "start": 6622.36, + "duration": 3.27 + }, + { + "text": "service on the Internet", + "start": 6624.49, + "duration": 3.27 + }, + { + "text": "use those results and put them back into", + "start": 6625.63, + "duration": 4.29 + }, + { + "text": "the page really just going to show the", + "start": 6627.76, + "duration": 4.02 + }, + { + "text": "power now that we get by taking", + "start": 6629.92, + "duration": 4.32 + }, + { + "text": "advantage of the JavaScript language we", + "start": 6631.78, + "duration": 4.65 + }, + { + "text": "have the ability now to not only use", + "start": 6634.24, + "duration": 4.08 + }, + { + "text": "JavaScript to be able to run code on the", + "start": 6636.43, + "duration": 3.54 + }, + { + "text": "client where we weren't able to before", + "start": 6638.32, + "duration": 3.72 + }, + { + "text": "were right before we only had Python", + "start": 6639.97, + "duration": 3.78 + }, + { + "text": "code that was running on a web server", + "start": 6642.04, + "duration": 4.2 + }, + { + "text": "but using JavaScript the really powerful", + "start": 6643.75, + "duration": 4.44 + }, + { + "text": "thing is now the ability to manipulate", + "start": 6646.24, + "duration": 4.05 + }, + { + "text": "the dog the ability to use JavaScript to", + "start": 6648.19, + "duration": 4.59 + }, + { + "text": "take the page and change the contents of", + "start": 6650.29, + "duration": 4.62 + }, + { + "text": "the page by updating things by reading", + "start": 6652.78, + "duration": 3.54 + }, + { + "text": "what happens to be on the page whether", + "start": 6654.91, + "duration": 3.12 + }, + { + "text": "it's inside of a particular element or", + "start": 6656.32, + "duration": 3.3 + }, + { + "text": "what a user happened to type in and", + "start": 6658.03, + "duration": 4.2 + }, + { + "text": "using that in conjunction with event", + "start": 6659.62, + "duration": 4.68 + }, + { + "text": "handlers ways that we can listen for", + "start": 6662.23, + "duration": 3.57 + }, + { + "text": "when the user clicks on something or", + "start": 6664.3, + "duration": 2.97 + }, + { + "text": "when the user Scrolls through something", + "start": 6665.8, + "duration": 3.54 + }, + { + "text": "or when the user types a key to be able", + "start": 6667.27, + "duration": 3.66 + }, + { + "text": "to respond and therefore make our", + "start": 6669.34, + "duration": 4.62 + }, + { + "text": "webpages all the more interactive next", + "start": 6670.93, + "duration": 4.59 + }, + { + "text": "time we'll continue our discussion of", + "start": 6673.96, + "duration": 2.94 + }, + { + "text": "JavaScript looking at how we can", + "start": 6675.52, + "duration": 3.24 + }, + { + "text": "leverage the features of JavaScript to", + "start": 6676.9, + "duration": 3.57 + }, + { + "text": "continue to build even more interesting", + "start": 6678.76, + "duration": 3.57 + }, + { + "text": "and engaging user interfaces so we'll", + "start": 6680.47, + "duration": 4.46 + }, + { + "text": "see you next time", + "start": 6682.33, + "duration": 2.6 + } +] \ No newline at end of file