1 / 18

THE BIG PICTURE

THE BIG PICTURE. How does JavaScript interact with the browser?. What sort of things can we do with JavaScript?. We can use JavaScript to process and check data entered in forms. What sort of things can we do with JavaScript?. We can use JavaScript to store and read information in “cookies.”

aldan
Download Presentation

THE BIG PICTURE

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. THE BIG PICTURE

  2. How does JavaScript interact with the browser?

  3. What sort of things can we do with JavaScript? We can use JavaScript to process and check data entered in forms.

  4. What sort of things can we do with JavaScript? We can use JavaScript to store and read information in “cookies.” Cookies are bits of data that are stored in the browser folder on the user’s local computer. They are used to track users (creepy) and are also used to customize content (convenient).

  5. What sort of things can we do with JavaScript? We can use JavaScript to dynamically show and hide content.

  6. What sort of things can we do with JavaScript? We can use JavaScript to dynamically access any part of the document.

  7. Loops in JavaScript. In Scratch we used loops to repeat a series of instructions for a fixed period of time. In JavaScript, we can do the same thing with a “for” loop.

  8. Conditional statements in JavaScript. In Scratch we use if and if-else statements to check if something was true. In JavaScript, we can do the same thing with if and if-else statements.

  9. Variables in JavaScript. In Scratch we use variables as information containers. They can hold numbers or letters (strings). In JavaScript we create variables by giving them a name.

  10. EXERCISE

  11. 1. Download the source files from TLEARN2: madlib.html and madlib.css

  12. 2. Link your HTML file to an external JavaScript file by adding the <script> line in the <head>.

  13. 3. Create a new file called madlib.js, and add the following code. Test by loading the page. Use your name instead of my name for the function. For example: zackFunction, ellenFunction.

  14. 4. Now, modify the page so the user will have to answer a question when the page loads. Your output should look like this: REFERENCE

  15. 5. NEXT: Ask the user for their name, and then greet them by name. Your output should look like this: REFERENCE From now on, these reference code blocks will show you the building blocks, will not give you the exact answer about how your code should look.

  16. 6. NEXT: Berate the user if their name is too long. Your output should look like this: REFERENCE Also, remember that you can find out the length of a string with: variableName.length

  17. 7. NEXT: Ask the user their name and then change the name of the author on the madlib page. (See following slide for hints.)

  18. REFERENCE FOR PREVIOUS SLIDE

More Related