Operation Down!
Your mission, should you decide to accept it, is to define a fruitful
function named moveDown that has four parameters
(inputs), representing a row, column, and two colors. It returns an
integer (an updated row value). It should perform the following four
steps:
- Invoke the function changeColor and supply three
arguments (inputs): the row, column, and first color (a simple
version of
changeColor is provided for testing)
- Increase the value of row by one. If it reaches 10,
change it to 0
- Invoke the function changeColor again, and supply
three arguments (inputs): the new value of row, column, and the second
color
- Return the new value of row
Write your function definition on the whiteboard set aside for your
team. After your definition has been cleared by one of your mission
leaders (Scott or Anna), implement and test your function as follows:
- Save a copy
of
on your Desktop. It's probably easiest to visit the file and then do
"File > Save Page As."
- You do not need to make any changes to this file!
You are welcome to look at it. Notice that it loads a
JavaScript file called
. That's the file
you'll be creating.
- Open Atom and type in your definition for the
function (just the function definition, with no <script> tags)
- Save the file on your Desktop with the name
- In your browser, use Open File in the File
menu to open the file from your Desktop
- Debug! When your function is working, the page should
look exactly like this:
Operation Down
When your moveDown function is complete, six headers will
appear below with row, column and color displayed for each call to the
changeColor function (there are three calls to moveDown
in the testing code, and this function calls changeColor twice)
When you're done, upload the code file to the
MI6 folder in the public_html
directory of the cs110d account. Your mission
leaders will give you the password.