Created
November 16, 2015 18:53
-
-
Save anonymous/8571869f85e5ac81f684 to your computer and use it in GitHub Desktop.
4 Functions // source http://jsbin.com/raheco
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>4 Functions</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> | |
| /* | |
| #1 | |
| Directions: Make a program that randomly displays a number 1 through 6 to the console | |
| Instructions: | |
| 1. return Math.random() to display a random number between 0 and 1 | |
| 2. Multiply your Math.random() function by 6 | |
| 3. Use Math.floor() to only display whole numbers between 0 and 5 | |
| 4. Add the number one to display a random number between 1 and 6 | |
| */ | |
| function dice() { | |
| //To do: Insert you code here | |
| } | |
| console.log(dice()); | |
| /* | |
| #2 | |
| Directions: Make a function that computes the average of two numbers | |
| Instructions: | |
| 1. Create a function called average with two parameters, x and y | |
| 2. Return the sum of x and y divded by 2 | |
| Test your function with console.log on 2 sets of inputs (numbers). | |
| */ | |
| //To do: Insert you code here | |
| /* | |
| #3 | |
| So Last Year Function | |
| Directions: Make a program that tells you the grade and age you were last year | |
| Instructions: | |
| 1. Declare a function called lastYear. | |
| 2. Give the function a parameter named year. | |
| 2b. Call the function with 2015 as the first parameter | |
| 3. In the body of the function, make a return statement that subtracts one from the parameter. | |
| 4. Create two console.log statements. | |
| 4a. one statement should print the grade you were in last year | |
| 4b. one statement should print the age you were in last year | |
| */ | |
| //To do: Insert you code here | |
| /* | |
| Bonus | |
| Directions: Write a function that returns the result of the following equation: 5a^2 + 4b + c. You should use the pow() function. Your function should take in three parameters (a,b,c). | |
| Test your function with console.log() on 3 different sets of inputs. | |
| */ | |
| //To do: Insert you code here | |
| </script> | |
| <script id="jsbin-source-html" type="text/html"> | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>4 Functions</title> | |
| </head> | |
| <body> | |
| </body> | |
| </html> | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript">/* | |
| #1 | |
| Directions: Make a program that randomly displays a number 1 through 6 to the console | |
| Instructions: | |
| 1. return Math.random() to display a random number between 0 and 1 | |
| 2. Multiply your Math.random() function by 6 | |
| 3. Use Math.floor() to only display whole numbers between 0 and 5 | |
| 4. Add the number one to display a random number between 1 and 6 | |
| */ | |
| function dice() { | |
| //To do: Insert you code here | |
| } | |
| console.log(dice()); | |
| /* | |
| #2 | |
| Directions: Make a function that computes the average of two numbers | |
| Instructions: | |
| 1. Create a function called average with two parameters, x and y | |
| 2. Return the sum of x and y divded by 2 | |
| Test your function with console.log on 2 sets of inputs (numbers). | |
| */ | |
| //To do: Insert you code here | |
| /* | |
| #3 | |
| So Last Year Function | |
| Directions: Make a program that tells you the grade and age you were last year | |
| Instructions: | |
| 1. Declare a function called lastYear. | |
| 2. Give the function a parameter named year. | |
| 2b. Call the function with 2015 as the first parameter | |
| 3. In the body of the function, make a return statement that subtracts one from the parameter. | |
| 4. Create two console.log statements. | |
| 4a. one statement should print the grade you were in last year | |
| 4b. one statement should print the age you were in last year | |
| */ | |
| //To do: Insert you code here | |
| /* | |
| Bonus | |
| Directions: Write a function that returns the result of the following equation: 5a^2 + 4b + c. You should use the pow() function. Your function should take in three parameters (a,b,c). | |
| Test your function with console.log() on 3 different sets of inputs. | |
| */ | |
| //To do: Insert you code here | |
| </script></body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| #1 | |
| Directions: Make a program that randomly displays a number 1 through 6 to the console | |
| Instructions: | |
| 1. return Math.random() to display a random number between 0 and 1 | |
| 2. Multiply your Math.random() function by 6 | |
| 3. Use Math.floor() to only display whole numbers between 0 and 5 | |
| 4. Add the number one to display a random number between 1 and 6 | |
| */ | |
| function dice() { | |
| //To do: Insert you code here | |
| } | |
| console.log(dice()); | |
| /* | |
| #2 | |
| Directions: Make a function that computes the average of two numbers | |
| Instructions: | |
| 1. Create a function called average with two parameters, x and y | |
| 2. Return the sum of x and y divded by 2 | |
| Test your function with console.log on 2 sets of inputs (numbers). | |
| */ | |
| //To do: Insert you code here | |
| /* | |
| #3 | |
| So Last Year Function | |
| Directions: Make a program that tells you the grade and age you were last year | |
| Instructions: | |
| 1. Declare a function called lastYear. | |
| 2. Give the function a parameter named year. | |
| 2b. Call the function with 2015 as the first parameter | |
| 3. In the body of the function, make a return statement that subtracts one from the parameter. | |
| 4. Create two console.log statements. | |
| 4a. one statement should print the grade you were in last year | |
| 4b. one statement should print the age you were in last year | |
| */ | |
| //To do: Insert you code here | |
| /* | |
| Bonus | |
| Directions: Write a function that returns the result of the following equation: 5a^2 + 4b + c. You should use the pow() function. Your function should take in three parameters (a,b,c). | |
| Test your function with console.log() on 3 different sets of inputs. | |
| */ | |
| //To do: Insert you code here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment