07 - Adding Javascript functionality

 1. JavaScript is the programming language of HTML and the Web. It helps make web pages _____________
Another way of saying this is that JavaScript programs the behaviour of web pages.

  static (still - and not moving)


  cluttered (full of various objects)


 2. In HTML, JavaScript code must be inserted between ____________
1. <script> and </script> tags.

2. <java> and </java> tags.

3. <javascript> and </javascript> tags.

4. <js> and </js> tags

  Option 4

  Option 3

  Option 1

  Option 2

 3. A JavaScript function is a block of JavaScript code, that can be executed when "called" for.
For example, a function can be called when an event occurs, like when the user clicks a button.



 4. Read the following list about where to place a Javascript script. Which statement is true>
Where to place JavaScript in an HTML page?

You can place any number of scripts in an HTML document.

1. Scripts can be placed in the <body> section of an HTML page

2. Scripts can be placed in the <head> section of an HTML page 

3. Scripts can be placed in either the <body> or <head> section of an HTML page

4. None of the above. Scripts can only be placed after the last closing </HTML> tag.

  Option 2

  Option 3

  Option 4

  Option 1

 5. Have a look at the code below. When you click the 'Try it' button, what will happen?
<!DOCTYPE html>
function myFunction() {
    document.getElementById("demo").innerHTML = "I just love HTML";


<h2>JavaScript in Head</h2>

<p id="demo">A Paragraph.</p>

<button type="button" onclick="myFunction()">Try it</button>


  The button will go to a random link

  The button will change into text which says "I just love HTML"

  The paragraph "A Paragraph" will be deleted from its position and put at the top of the page

  The paragraph "A Paragraph" will change to "I just love HTML"

 6. The number '11' should be displayed underneath 'My First Web page'. What is missing?
<!DOCTYPE html>
<h2>My First Web Page</h2>
<p id=""></p>
document.getElementById("demo").innerHTML = 5 + 6;

  There is nothing missing - but it will display '5' to the screen, not 11.

  There is nothing missing. It will work fine.

  Line 5 is missing 'demo' in between the speech marks

  Line 6 should have an additional closing script tag.

 7. The following trinket shows an HTML page with embedded JavaScript to create a snake game. Where is the Javascript code?

  The JavaScript code is all contained in the index.html page

  There is no JavaScript code - it is purely done in HTML

  The JavaScript code is all on line 23. One line is very powerful!

  In a separate file called 'snake.js' and it is called from index.html on line 23

 8. JavaScript is the same language as Java.



 9. Here is another example of a JavaScript powered game. The JavaScript is in an _________ file.





 10. Read the excerpt below. Fill in the blanks for CSS.
JavaScript is one of the 3 languages all web developers must learn:

   1. HTML to define the content of web pages

   2. CSS to specify the ______________________

   3. JavaScript to program the behavior of web pages

  layout of webpages

  names and saving types

  images used in web pages (It is not possible to use an image without CSS)

  development of webpages (particularly the interactivity)