Created
May 4, 2017 23:02
-
-
Save charstarstars/7dc5a2c8cd2a144ded12b472f9d62abf to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=7dc5a2c8cd2a144ded12b472f9d62abf
This file contains 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>Calculator javascript</title> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains 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
// All the code you will need to create for this project will be completed below | |
// Your functions must be called the following: | |
// multiply, divide, subtract, add, power, square_root, logBase10, generateRandomNumber | |
// 1. divide | |
// write a function named "divide" that takes in two parameters and returns their quotient | |
function divide(x,y) { | |
//Write your code below this line | |
} | |
// 2. multiply | |
// write a function named | |
// "multiply" that takes in two | |
// parameters and returns | |
// their product | |
// 3. subtract | |
// write a function named | |
// "subtract" that takes in two | |
// parameters and returns | |
// their difference | |
// 4. add | |
// write a function named "add" that takes in two parameters and returns their sum | |
// 5. power | |
// write a function named "power" that takes in two parameters and returns their result | |
// 6. square_root | |
// write a function named "square_root" that takes in one parameter and returns their result | |
// 7. logBase10 | |
// write a function named "logBase10" that takes in one parameter and returns their result | |
// 8. generateRandomNumber | |
// write a function named "generateRandomNumber" that takes in no parameters and returns a random number | |
// BONUS: write assertions to test whether your functions work! | |
// Here are some examples for divide(x,y), can you write more for the other functions? | |
// | |
// console.assert(divide(1,1) === 1, "1/1 should equal 1"); | |
// console.assert(divide(1,2) === 0.5, "1/2 should equal 0.5"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment