CPSC 120, Fall 2011
About the Second Test


The second test in CS 120 will be given in class on Wednesday, October 19. It will concentrate on what we have covered since the previous test. That means mainly JavaScript, including canvas graphics. It also covers a few HTML form elements and some of their properties and events. The test covers material from labs 5, 6, and 7 as well as material from class and from the textbook. You can consult the lists of material covered and readings from the textbook for weeks 4 through 7, on the course web page at http://math.hws.edu/eck/cs120.

As usual, the test will be a mixture of various kinds of questions, such as: definitions, short essays, longer essays, writing JavaScript code to do drawing or other tasks, writing and using HTML form elements, and reading JavaScript code to say what it does. There is no CSS on this test.


Here are some terms and ideas that you should be familiar with:

programming
JavaScript
the HTML <script> element and how it is used

variables
declaring variables with var
assignment statements, such as:   num = 3;   or   x = x + 1;
arithmetic expressions, such as:  x + y/2
operators for arithmetic:   +  -  *   /
Adding onto a string with +, such as:  "Hello, " + userName
comments in JavaScript

functions
parameters in functions
calling functions
built-in functions, including Math.floor(x) and Math.random()
using Math.floor and Math.random to make random integers
dialog functions,  alert(message)  and  prompt(question)
defining new functions in JavaScript
calling functions in event handlers, such as:  <button onclick="func()"...

functions for drawing on a canvas, using a 2d context named graphics:
    graphics.clearRect(x,y,width,height)
    graphics.fillRect(x,y,width,height)
    graphics.stokeRect(x,y,width,height)
    graphics.fillText(string,x,y)
    graphics.strokeText(string,x,y)
variables in a graphics context that affect the drawing:
    graphics.lineWidth
    graphics.fillStyle
    graphics.strokeStyle
    graphics.font
    graphics.globalAlpha
other graphics functions that were defined for you to use:
    strokeLine(x1,y1,x2,y2)
    strokeCircle(x,y,radius)
    fillCircle(x,y,radius)
    randomColor()

control statements
if statements, with and without else
expressions for making tests, such as:  password == "sesame"  
operators for comparing values:   ==  !=  <  >  <=   >=
for loops
basic counting loops, such as:  for ( i=1; i <= 10; i = i + 1 )
using  i++  as an abbreviation for  i = i + 1
using variables to control for loops, such as:
                         for ( n = 0; n < quantity; n++ )
using different updates in for loops, such as:
                         for ( n = 0; n <= 600; n = n + 50 )
                         
HTML button elements and onclick:  <button onclick="func()"...
HTML input box elements:  <input type="text" ...
HTML password elements:   <input type="password" ...
HTML <select> and <option> elements
the onchange event handler for <select>
using the id attribute in HTML elements
accessing HTML elements by id in JavaScript:
                         document.getElementById(idname)
the value property of an input box:
                         document.getElementById(boxid).value
the innerHTML property of an element:
                         document.getElementById(id).innerHTML