Preview

04 - Functions GameDesign ASCII Movement Colour

 1. JavaScript is untyped language. This means that a JavaScript variable can hold a value of any data type. You don't have to tell JavaScript during variable declaration what type of value the variable will hold.
var name = "Marvin"; or var age = 30; as opposed to Dim name as string (VB.Net)

  False

  True

 2. Local Variables ? A local variable will be visible only within a function where it is defined. The other type is:

  global' which can be defined and accessed anywhere in your code

  foreign' which can be defined only inside another variable

  None of these options are valid answers

  mobile' which refers to a variable that can be moved easily

 3. In the following diagram, fill in the blanks and identify the coordinates for No.1 and No.2.
computercoordinates_q1.png

  None of these options are valid answers

  1 = (1,2) 2= (5,2)

  1 = (7,9) 2= (8,2)

  1 = (5,3) 2= (6,1)

 4. In the following example, if the following code snippet (decrementing y)was being applied to the movement of a shape, the shape would:
y = y - 10 is:
explaining_y_coordinate_decrementation.png

  cause an error, as it is not possible to have a - y coodinate or option

  move down (toward the bottom of the screen) on the y axis

  move upwards (or go back up rather than down the y axis)

  move across the x axis, as the negative sign is being used

 5. In the following example, what is the number 87 referring to?
explaining_y_coordinate_decrementation.png

  It is referring to a hexadecimal number that can be converted directly into Binary

  It is referring to the numbers '8' and '7' which could be used to control the shape

  It is referring to the maximum number of key strokes allowed by the player (this can be changed)

  It is referring to the ASCII value of the 'W' key, which is 87

 6. The following function will turn a shape red if placed just ______ the code for the shape.
function_whatismissing.png

  above

  outside the html code

  inside

  to the right of

 7. What is missing from this function?
function_whatismissing.png

  a curly brace to end the function

  a colon to end the function

  a comma to end the function

  a full stop to end the function

 8. In the following code, what is clearCanvas(); doing?
if (e.keyCode == 65) {
				clearCanvas();
				x = x - 10;
				turngreen();
				ctx.fillRect(x, y, 50, 30);
			
			}

  It is calling a function called 'clearCanvas', when a specific keycode is pressed

  It is creating a variable called 'clear' and applying it to the canvas

  It is creating an if function that is cleared if the canvas is clear

  None of these options are valid answers

 9. In the following code, what is the 50 and 30 referring to?
ctx.fillRect(x, y, 50, 30);

  the width and the height of the shape

  the x and the y coordinate of the shape

  the width and the x coordinate of the shape

  the height and the y coordinate of the shape

 10. A function is a group of_______ code which can be called anywhere in your program. This eliminates the need of writing the same code again and again

  constant

  unpredictable

  variable

  reusable