ASSIGNMENT: Study the sample code and concentrate of the block of code which begins with function box(s,x,y,dy). This is how functions are defined in JavaScript. Functions are blocks of code which can be called repeatedly. In fact, the last three lines of the script are all calls to the function named box. The values in the parentheses are called parameters. Functions can be defined to accept any number of parameters. In the case of the box function, it takes four parameters with the first being a string value and the other three being integer values. Notice that the last call to box contains -1 as its last parameter. What is special about this box compared to the previous two? So your task will be to recreate the diagram shown to the right using multiple calls to the box function. For extra credit you might figure out how you might use a couple arrays and a for-loop to make it so that only one call to box appears in the code. |