Operation Right!
Your mission, should you decide to accept it, is to define a fruitful
function named moveRight that has four parameters
(inputs), representing a row, column, and two colors. Your function
will return an integer (an updated column value). Your function 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 column by one. If the value of column
reaches 10, change it to 0
- Invoke the function changeColor again, and supply
three arguments (inputs): the row, new value of column, and second
color
- Return the new value of column
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 Right
When your moveRight 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 moveRight
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.