The goal of this project is to continue practicing JavaScript concepts including functions, loops, switch, and simple recursion. You will create several pages with JavaScript programs.
Below are descriptions for each of the pages you will create. Please read descriptions carefully and capture every detail. Since coding is very detail-oriented, part of your grade will depend on how carefully you follow these instructions.
You will create the following HTML/JS pages. Further details on each page will be given below.
This program should prompt the user for a number, an operator (+, -, *, or /), and another number. It should then print the input and result on the page in the form "<first number> <operator> <second number> = <answer>". For example, "5 + 4 = 9".
Requirements. Your program must do/include the following:
This program should prompt the user for a number of rows, then for a number of columns. It should then create a table with the corresponding number of rows and columns. Each cell in the table should be a random color.
Requirements. Your program must do/include the following:
// Returns a random number from 0 to 255 for color values function randomColorValue() { return Math.floor(Math.random() * 256); }
This program should prompt the user for a number and a programming preference ("while", "for", or "recursion"). It should then call one of three functions: "whileCollatz()", "forCollatz()", or "recursiveCollatz". These functions should each perform the same task of printing to Collatz sequence as specified below. You can find more information on the Collatz conjecture here and see some videos on it here and here.
Requirements. Your program must do/include the following:
Math.floor(Math.sqrt(num))
This program should visualize a Collatz sequence in some different way than the previous part of the project. This part is open ended, but you should use some CSS/HTML we have covered in this class. You can use colors, tables, etc. any way you wish to represent the numbers in the sequence. For example, you could print a series of squares which change in color and size based on the number they represent.
You are allowed to resuse code from your Collatz.html file. Essentially, this part of the project asks you to replace the function printNumber(num) with something more interesting.
Hint: If you are using color, you may find it useful to map an arbitrary number to a color value (0-255). One simple way to do this is using the mod operator (%). Remember that mod gives you the remainder from integer division. The following code converts a number, num, into a value between 0 and 255 and assigns it to the variable colorValue.
var colorValue = num % 256;
You will submit a zip file. Please be sure that all of your work (your HTML files and any other necessary files) are in a folder called "Project3". Create a zip file that includes this folder, as follows. On Windows, right-click the folder, then choose "send to, compressed (zipped) folder". DO NOT USE A UTILITY LIKE 7-ZIP OR WINRAR. On a Mac, right-click the folder, then choose "Compress yourFolderName".
You will not receive credit for submitting a file that is not a standard "zip" file. In particular, "rar" files or "7z" files will not be graded. Submit the zip file to the submit server by logging in, selecting Project 3 (Functions), and uploading the zip file to the server. You may submit as many times as you like. We will only grade the last submission. See syllabus for late policy.
After you have submitted the project, we strongly recommend downloading your submission from the submit server. It will give you a zip file. Unzip this file and verify that the contents are as they should be. It should contain all of your HTML files and your photo.
Project adapted from Nelson Padua-Perez and Fawzi Emad.