Presentation is loading. Please wait.

Presentation is loading. Please wait.

THE BIG PICTURE. How does JavaScript interact with the browser?

Similar presentations


Presentation on theme: "THE BIG PICTURE. How does JavaScript interact with the browser?"— 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 line in the.

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. 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. Your output should look like this: REFERENCE

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

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


Download ppt "THE BIG PICTURE. How does JavaScript interact with the browser?"

Similar presentations


Ads by Google