diff --git a/Javascript/week0/issues/0.0-done.md b/Javascript/week0/issues/0.0-done.md deleted file mode 100644 index 908b909f..00000000 --- a/Javascript/week0/issues/0.0-done.md +++ /dev/null @@ -1 +0,0 @@ -Congrats! You're finished. diff --git a/Javascript/week0/issues/0.0-response.md b/Javascript/week0/issues/0.0-response.md deleted file mode 100644 index 16693b11..00000000 --- a/Javascript/week0/issues/0.0-response.md +++ /dev/null @@ -1 +0,0 @@ -When a section is completed, a new issue will be created with the next step. [Click here to start!]({{ repoUrl }}/issues/) diff --git a/Javascript/week0/issues/0.0-welcome.md b/Javascript/week0/issues/0.0-welcome.md deleted file mode 100644 index ed87ef87..00000000 --- a/Javascript/week0/issues/0.0-welcome.md +++ /dev/null @@ -1,3 +0,0 @@ -Welcome to Bit Project's Github Learning Lab on JavaScript. - -This Learning Lab is going to teach you some of the fundamental coding skills you will need to start building awesome Javascript projects :rocket: diff --git a/Javascript/week1/issues/1.1-fizzbuzz.md b/Javascript/week1/issues/1.1-fizzbuzz.md deleted file mode 100644 index dd394275..00000000 --- a/Javascript/week1/issues/1.1-fizzbuzz.md +++ /dev/null @@ -1,121 +0,0 @@ -## FizzBuzz In SPACE - -*For this assignment, you will follow the instructions and complete a task showing your knowledge of the subject at the end. If at any moment you need help, feel free to contact your TAs.* - -### :airplane: Starting off - -Create a file called fizzbuzz.js - -**FizzBuzz** - -FizzBuzz is a program used to demonstrate basic functionality of a language, often when switching between programing languages or as an introduction (that's us!) to first learning a language. - -The goals of the program is to go through the numbers from 1 to 100 and print "fizz" whenever a number is divisible by 3, print "buzz" when it's divisible by 5, print "fizzbuzz" when it's divisible by both 3 and 5, and print the number when it's not divisible by either. For our program, you will do something very similar: - -For the numbers from 1 to 100: -* print πŸ‘½ and the number if it is divisible by 3 -* print πŸš€ and the number if it is divisible by 5 -* print πŸ›° and the number if it is divisible by both 3 and 5 -* print πŸ’© and the number if it is not divisible by either 3 or 5 - -Tip: copy paste the emojis to get it into your code! - -### Help: - -* [Loops in Javascript](https://www.w3schools.com/js/js_loop_for.asp) -* [Conditions in Javascript](https://www.w3schools.com/js/js_if_else.asp) -* [Command Line Arguments in Javascript](https://nodejs.org/en/knowledge/command-line/how-to-parse-command-line-arguments/) -* [console.log Method](https://www.w3schools.com/jsref/met_console_log.asp) - - -### :pencil: Commenting your Code - -Use in line comments to explain how your code works. Commenting your code helps ensure that you understand what is happening, and helps the code reviewer read through your code easily. For example: - -**Great example:** -``` -var i; // Initialize a variable -for (i = 0; i < nums.length; i++) { // Initialize a for loop that iterates from 0 to length of the nums array - nums[i]+5; // At every iteration, add the i-th integer in the nums array to the text variable -} // End of loop -``` - -When you start writing more code (200+ lines) you will want to do the next example. For this course, your code should not extend past 50-100 lines and we want to use your comments to see how well you understand the concepts and language, so it's better to use the previous example. - -**Okay example:** -``` -// This code uses a for loop to iterate through the entire nums array and add 5 to each element -var i; -for (i = 0; i < nums.length; i++) { - nums[i]+5; -} -``` - -**Don't do this:** -``` -// Add 5 to all values in nums array -var i; -for (i = 0; i < nums.length; i++) { - nums[i]+5; -} -``` - -### :red_car: Running your Code - -1. Save your file -2. Make sure you're in the same directory in which you saved your fizzbuzz.js file - -In this program, you need to allow your program to take a second argument, so: -3. To run your fancy new program, type: ```node fizzbuzz.js``` with an integer between 1-100 in terminal - -### :pencil2: Testing - -To test your code, run it with different integers in the program argument to see what happens. - -**Test Case 1:** - -If you run ```node fizzbuzz.js 5``` the output should be: - -``` -πŸ’© 1 -πŸ’© 2 -πŸ‘½ 3 -πŸ’© 4 -πŸš€ 5 -``` - -**Test Case 2:** - -If you run ```node fizzbuzz.js 17``` the output should be: - -``` -πŸ’© 1 -πŸ’© 2 -πŸ‘½ 3 -πŸ’© 4 -πŸš€ 5 -πŸ‘½ 6 -πŸ’© 7 -πŸ’© 8 -πŸ‘½ 9 -πŸš€ 10 -πŸ’© 11 -πŸ‘½ 12 -πŸ’© 13 -πŸ’© 14 -πŸ›° 15 -πŸ’© 16 -πŸ’© 17 -``` - -**Output example:** - -![](fizzbuzz.png) - -### βœ… Submit - -**Task 1: Complete the FizzBuzz program as described above** - -Commit a file called fizzbuzz.js - -Good job, you're fizzing and buzzing in space! diff --git a/Javascript/week1/issues/1.2-github.md b/Javascript/week1/issues/1.2-github.md deleted file mode 100644 index b96857e6..00000000 --- a/Javascript/week1/issues/1.2-github.md +++ /dev/null @@ -1,17 +0,0 @@ -## Learning GitHub - -*For this assignment, you will follow the instructions and complete a task showing your knowledge of the subject at the end. If at any moment you need help, feel free to contact your TAs.* - -### GitHub - -GitHub is a cloud-based repository hosting service that is widely used in the tech industry. It allows teams to use Git for version control, collaboration, and file management. If you don't know what Git is, it's a version-control system for tracking changes, managing state, and concurrently developing on the same files or directories. Git and Github's tools are specifically designed to make coordinating work easier, and they are one of the most pervasive shared tools among students and the industry. - -If you want to learn more about *what it is* and *how to use it*, try taking [this](https://lab.github.com/githubtraining/introduction-to-github#:~:text=Audience.%201%20Assign%20yourself.%20Assign%20the%20first%20issue,an%20issue.%20%204%20Create%20a%20branch.%20) GitHub Learning Lab Course. After finishing it, you will have a strong understanding of all the features GitHub has to offer. To make an account, go to: https://github.com/join to sign up. After making an account, you're all set to complete Task 3! - - - -**Task 2: create a repository and commit your homework javascript file to it (make sure you know key functions like commits, forking, pull request, branch, etc).** - - - -Good job, you're done with both parts! diff --git a/Javascript/week1/issues/1.3-terminal.md b/Javascript/week1/issues/1.3-terminal.md deleted file mode 100644 index 8b718e8f..00000000 --- a/Javascript/week1/issues/1.3-terminal.md +++ /dev/null @@ -1,51 +0,0 @@ -## Terminal - -### Mac: -* Click the "spotlight search" icon in the top right corner. -* Search for "terminal". -* Click terminal to open it (right click it to run as admin). - -![Terminal Instructions](https://github.com/Bahburs/javascript-course/blob/main/images/terminal.png) - -### Windows: - -* Click the search bar in the bottom left corner. -* Search for "command prompt". -* Click terminal to open it (right click and say "run as administrator" to run as admin). - -![Command Prompt Instructions](https://github.com/Bahburs/javascript-course/blob/main/images/commandprompt.png) - - - -### Basic Terminal Commands - -**Shortcuts:** -* `.` : current directory -* `..` : previous directory -* `~` : home directory - -**Directory (folder):** -* `pwd` : print current directory (if you're lost, or need the full path to the current directory you're in) -* `ls` : list everything in current directory (super useful to know which files/folders you can currently access) -* `ls [directory path]` : list everything in current [directory path] -* `cd [directory path]` : change directory to [directory path] - * `cd /home/users/Shreya/Documents/terminal.md` - * `cd .` : change directory to current directory (doesn't really do much) - * `cd ..` : change directory to previous directory (useful) - * `cd ../some_folder_name` : change directory to some_folder_name directory in previous directory (sort of like going back one and into another folder) - * `cd .` : change directory to home directory - -**Opening files (in terminal, you don't need this if you're using GitHub desktop)** -In file: -* `vi` : open file -* `[ECS] -> *+w+q` : save file -* more useful commands: https://www.cs.colostate.edu/helpdocs/vi.html - -**Running a program** -* `./[program_name.extension]` [any other expected arguments] - * `./sumarray.js` (week 2) - * `./romanint.js 78` (week 3) - -Find more useful commands: https://www.techrepublic.com/article/16-terminal-commands-every-user-should-know/ - -Not sure which command to use or how it works? **Google it!** Everyone uses terminal so there's a lot of useful content/blogs/video tutorials online. You can also ask your mentor for help if you're not sure where to start. diff --git a/Javascript/week1/issues/fizzbuzz.png b/Javascript/week1/issues/fizzbuzz.png deleted file mode 100644 index 7ea7960f..00000000 Binary files a/Javascript/week1/issues/fizzbuzz.png and /dev/null differ diff --git a/Javascript/week2/code/solution/2.1-romancalc-phase1.js b/Javascript/week2/code/solution/2.1-romancalc-phase1.js deleted file mode 100644 index 0ff1e689..00000000 --- a/Javascript/week2/code/solution/2.1-romancalc-phase1.js +++ /dev/null @@ -1,15 +0,0 @@ -// Initialize an array that will hold the values to be calculated (from the command line) -function get_args() { - const operand1 = process.argv[2]; - const operator = process.argv[3]; - const operand2 = process.argv[4]; - let op = [operand1, operator, operand2]; - return op; -} - -// Test cases: -/* run romancalc.js a b c*/ -let op = get_args(); -console.log("The first operand is: ", op[0]); -console.log("The second operand is: ", op[2]); -console.log("The operator is: ", op[1]); \ No newline at end of file diff --git a/Javascript/week2/code/solution/2.2-romancalc-phase2.js b/Javascript/week2/code/solution/2.2-romancalc-phase2.js deleted file mode 100644 index bea093bc..00000000 --- a/Javascript/week2/code/solution/2.2-romancalc-phase2.js +++ /dev/null @@ -1,49 +0,0 @@ -//PHASE 1: - -// Initialize an array that will hold the values to be calculated (from the command line) -function get_args() { - var operand1 = process.argv[2]; - var operator = process.argv[3]; - var operand2 = process.argv[4]; - let op = [operand1, operator, operand2]; - return op; -} - -// PHASE 2: - -function calculate() { - // Use previously built get_args function to get operators and operand - let op = get_args(); - var a = Number(op[0]); - var operator = op[1]; - var b = Number(op[2]); - - // Initialize variable to hold result of operations - var result = 0; - - // Use conditions to determine what the operation is from the user input and calculate the result - if(operator == '+') { - result = a + b; - } else if(operator == '-') { - result = a - b; - } else if(operator == 'x') { - result = a * b; - } else if(operator == '/') { - result = a / b; - } else if(operator == '^') { - result = a ** b; - } else if(operator == '%') { - result = a % b; - } - - return result; -} - -// Testing: -/* -Run romancalc.js a b c -where a and c are numbers -and b is the operator. -This code is sensitive to the spacing in the user input (command line). -*/ -console.log(calculate()); \ No newline at end of file diff --git a/Javascript/week2/code/solution/2.3-romancalc-phase3.js b/Javascript/week2/code/solution/2.3-romancalc-phase3.js deleted file mode 100644 index 1d3ada7b..00000000 --- a/Javascript/week2/code/solution/2.3-romancalc-phase3.js +++ /dev/null @@ -1,89 +0,0 @@ -//PHASE 1: - -// Initialize an array that will hold the values to be calculated (from the command line) -function get_args() { - const operand1 = process.argv[2]; - const operator = process.argv[3]; - const operand2 = process.argv[4]; - let op = [operand1, operator, operand2]; - return op; -} - -// PHASE 2: - -function calculate() { - // Use previously built get_args function to get operators and operand - let op = get_args(); - var a = Number(op[0]); - var operator = op[1]; - var b = Number(op[2]); - - // Initialize variable to hold result of operations - var result = 0; - - // Use conditions to determine what the operation is from the user input and calculate the result - if(operator == '+') { - result = a + b; - } else if(operator == '-') { - result = a - b; - } else if(operator == 'x') { - result = a * b; - } else if(operator == '/') { - result = a / b; - } else if(operator == '^') { - result = a ^ b; - } else if(operator == '%') { - result = a % b; - } - - return result; -} - -// PHASE 3: - -// Learn more about associative arrays in JS: https://www.xul.fr/javascript/associative.php -const letterVals = { - "I": 1, - "V": 5, - "X": 10, - "L": 50, - "C": 100, - "M": 1000 -}; - -// Function (romanToInt) that takes input as a parameter and returns int from roman value, ex. XXVII: 27, XIV: 14 -function romanToInt(input) { - if (input === "") { - return 0; - } - romanArr = input.split(""); - - len = romanArr.length - value = 0; - romanArr.forEach((item, index) => { - if (item === "I" && index + 1 < len && - (romanArr[index + 1] === "V" || romanArr[index + 1] === "X")) { - // I can be placed before V (5) and X (10) to make 4 and 9 - value -= 2 * letterVals[item]; - } else if (item === "X" && index + 1 < len && - (romanArr[index + 1] === "L" || romanArr[index + 1] === "C")) { - // X can be placed before L (50) and C (100) to make 40 and 90. - value -= 2 * letterVals[item]; - } else if (item === "C" && index + 1 < len && - (romanArr[index + 1] === "D" || romanArr[index + 1] === "M")) { - // C can be placed before D (500) and M (1000) to make 400 and 900 - value -= 2 * letterVals[item]; - } - - value += letterVals[item]; - }); - - return value; -} - -// Testing -console.log(romanToInt(process.argv[2])); -//console.log(romanToInt("4")); -//console.log(romanToInt("IV")); -//console.log(romanToInt("XIV")); -//console.log(romanToInt("XXVII")); \ No newline at end of file diff --git a/Javascript/week2/code/solution/2.4-romancalc-phase4.js b/Javascript/week2/code/solution/2.4-romancalc-phase4.js deleted file mode 100644 index cf969a5d..00000000 --- a/Javascript/week2/code/solution/2.4-romancalc-phase4.js +++ /dev/null @@ -1,100 +0,0 @@ -//PHASE 1: - -// Initialize an array that will hold the values to be calculated (from the command line) -function get_args() { - const operand1 = process.argv[2]; - const operator = process.argv[3]; - const operand2 = process.argv[4]; - let op = [operand1, operator, operand2]; - return op; -} - -// PHASE 2: - -function calculate() { - // Use previously built get_args function to get operators and operand - let op = get_args(); - var a = Number(op[0]); - var operator = op[1]; - var b = Number(op[2]); - - // Initialize variable to hold result of operations - var result = 0; - - // Use conditions to determine what the operation is from the user input and calculate the result - if(operator == '+') { - result = a + b; - } else if(operator == '-') { - result = a - b; - } else if(operator == 'x') { - result = a * b; - } else if(operator == '/') { - result = a / b; - } else if(operator == '^') { - result = a ^ b; - } else if(operator == '%') { - result = a % b; - } - - return result; -} - -// PHASE 3: - -// Learn more about associative arrays in JS: https://www.xul.fr/javascript/associative.php -const letterVals = { - "I": 1, - "V": 5, - "X": 10, - "L": 50, - "C": 100, - "M": 1000 -}; - -// Function (romanToInt) that takes input as a parameter and returns int from roman value, ex. XXVII: 27, XIV: 14 -function romanToInt(input) { - if (input === "") { - return 0; - } - romanArr = input.split(""); - - len = romanArr.length - value = 0; - romanArr.forEach((item, index) => { - if (item === "I" && index + 1 < len && - (romanArr[index + 1] === "V" || romanArr[index + 1] === "X")) { - // I can be placed before V (5) and X (10) to make 4 and 9 - value -= 2 * letterVals[item]; - } else if (item === "X" && index + 1 < len && - (romanArr[index + 1] === "L" || romanArr[index + 1] === "C")) { - // X can be placed before L (50) and C (100) to make 40 and 90. - value -= 2 * letterVals[item]; - } else if (item === "C" && index + 1 < len && - (romanArr[index + 1] === "D" || romanArr[index + 1] === "M")) { - // C can be placed before D (500) and M (1000) to make 400 and 900 - value -= 2 * letterVals[item]; - } - - value += letterVals[item]; - }); - - return value; -} - -// https://stackoverflow.com/questions/9083037/convert-a-number-into-a-roman-numeral-in-javascript -function intToRoman(input) { - if (isNaN(input)) - return NaN; - var digits = String(+input).split(""), - key = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM", - "","X","XX","XXX","XL","L","LX","LXX","LXXX","XC", - "","I","II","III","IV","V","VI","VII","VIII","IX"], - roman = "", - i = 3; - while (i--) - roman = (key[+digits.pop() + (i * 10)] || "") + roman; - return Array(+digits.join("") + 1).join("M") + roman; -} - -// Testing -console.log(intToRoman(process.argv[2])); \ No newline at end of file diff --git a/Javascript/week2/code/solution/2.5-romancalc-phase5.js b/Javascript/week2/code/solution/2.5-romancalc-phase5.js deleted file mode 100644 index 7aecd2f6..00000000 --- a/Javascript/week2/code/solution/2.5-romancalc-phase5.js +++ /dev/null @@ -1,116 +0,0 @@ -function isNumber(n) { return /^-?[\d.]+(?:e-?\d+)?$/.test(n); } - -// PHASES 3 & 4 shifted to top: - -// Learn more about associative arrays in JS: https://www.xul.fr/javascript/associative.php -const letterVals = { - "I": 1, - "V": 5, - "X": 10, - "L": 50, - "C": 100, - "M": 1000 -}; - -// Function (romanToInt) that takes romanString as a parameter and returns int from roman value, ex. XXVII: 27, XIV: 14 -function romanToInt(romanString) { - if (romanString === "") { - return 0; - } - romanArr = romanString.split(""); - - len = romanArr.length - value = 0; - romanArr.forEach((item, index) => { - if (item === "I" && index + 1 < len && - (romanArr[index + 1] === "V" || romanArr[index + 1] === "X")) { - // I can be placed before V (5) and X (10) to make 4 and 9 - value -= 2 * letterVals[item]; - } else if (item === "X" && index + 1 < len && - (romanArr[index + 1] === "L" || romanArr[index + 1] === "C")) { - // X can be placed before L (50) and C (100) to make 40 and 90. - value -= 2 * letterVals[item]; - } else if (item === "C" && index + 1 < len && - (romanArr[index + 1] === "D" || romanArr[index + 1] === "M")) { - // C can be placed before D (500) and M (1000) to make 400 and 900 - value -= 2 * letterVals[item]; - } - - value += letterVals[item]; - }); - - return value; -} - -// https://stackoverflow.com/questions/9083037/convert-a-number-into-a-roman-numeral-in-javascript -function intToRoman(input) { - if (isNaN(input)) - return NaN; - var digits = String(+input).split(""), - key = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM", - "","X","XX","XXX","XL","L","LX","LXX","LXXX","XC", - "","I","II","III","IV","V","VI","VII","VIII","IX"], - roman = "", - i = 3; - while (i--) - roman = (key[+digits.pop() + (i * 10)] || "") + roman; - return Array(+digits.join("") + 1).join("M") + roman; -} - -//PHASE 1 & PHASE 5: - -// Initialize an array that will hold the values to be calculated (from the command line) -function get_args() { - if (!isNumber(process.argv[2])) { - var operand1 = romanToInt(process.argv[2]); - } else { - var operand1 = process.argv[2]; - } - - if(!isNumber(process.argv[4])) { - var operand2 = romanToInt(process.argv[4]); - } else { - var operand2 = process.argv[4]; - } - - var operator = process.argv[3]; - let op = [operand1, operator, operand2]; - return op; -} - -// PHASE 2: - -function calculate() { - // Use previously built get_args function to get operators and operand - let op = get_args(); - var a = Number(op[0]); - var operator = op[1]; - var b = Number(op[2]); - - // Initialize variable to hold result of operations - var result = 0; - - // Use conditions to determine what the operation is from the user input and calculate the result - if(operator == '+') { - result = a + b; - } else if(operator == '-') { - result = a - b; - } else if(operator == 'x') { - result = a * b; - } else if(operator == '/') { - result = a / b; - } else if(operator == '^') { - result = a ** b; - } else if(operator == '%') { - result = a % b; - } - - return result; -} - -var result = calculate(); -op = get_args(); - -console.log("Results:"); -console.log(result); -console.log(intToRoman(result)); \ No newline at end of file diff --git a/Javascript/week2/code/solution/twilioquest-code/addFirstToLast.js b/Javascript/week2/code/solution/twilioquest-code/addFirstToLast.js deleted file mode 100644 index 1c780b22..00000000 --- a/Javascript/week2/code/solution/twilioquest-code/addFirstToLast.js +++ /dev/null @@ -1,7 +0,0 @@ -function addFirstToLast(stringArray) { - if (stringArray.length === 0) { - return ""; - } else { - return stringArray[0] + stringArray[stringArray.length-1]; - } -} \ No newline at end of file diff --git a/Javascript/week2/code/solution/twilioquest-code/enhancedLifeDetector.js b/Javascript/week2/code/solution/twilioquest-code/enhancedLifeDetector.js deleted file mode 100644 index 6714e0f9..00000000 --- a/Javascript/week2/code/solution/twilioquest-code/enhancedLifeDetector.js +++ /dev/null @@ -1,11 +0,0 @@ -const treeStatus = process.argv[2]; - -if (treeStatus === '0') { - console.log("alive"); -} else if (treeStatus === "1") { - console.log("flowering"); -} else if (treeStatus === "2") { - console.log("shedding"); -} else { - console.log("other"); -} \ No newline at end of file diff --git a/Javascript/week2/code/solution/twilioquest-code/freighterInventory.js b/Javascript/week2/code/solution/twilioquest-code/freighterInventory.js deleted file mode 100644 index 02c6acd0..00000000 --- a/Javascript/week2/code/solution/twilioquest-code/freighterInventory.js +++ /dev/null @@ -1 +0,0 @@ -const inventory = ["Ducktypium Ore", "Uranium Rod", "Ruthenium Isotopes", "Concave Lens", "Refraction Panel"] \ No newline at end of file diff --git a/Javascript/week2/code/solution/twilioquest-code/getFirstAmountSorted.js b/Javascript/week2/code/solution/twilioquest-code/getFirstAmountSorted.js deleted file mode 100644 index 69616437..00000000 --- a/Javascript/week2/code/solution/twilioquest-code/getFirstAmountSorted.js +++ /dev/null @@ -1,9 +0,0 @@ -function getFirstAmountSorted(stringArray, number){ - stringArray.sort(); - //console.log(stringArray); - const slicedArray = stringArray.slice(0, number); - return slicedArray; -} - -const newArray = getFirstAmountSorted(['cat', 'apple', 'bat'], 2); -console.log(newArray); \ No newline at end of file diff --git a/Javascript/week2/code/solution/twilioquest-code/northBridgeControl.js b/Javascript/week2/code/solution/twilioquest-code/northBridgeControl.js deleted file mode 100644 index d5c9c803..00000000 --- a/Javascript/week2/code/solution/twilioquest-code/northBridgeControl.js +++ /dev/null @@ -1,5 +0,0 @@ -const command = process.argv[2]; - -if (command === "EXTEND") { - console.log("Extending bridge!"); -} \ No newline at end of file diff --git a/Javascript/week2/code/solution/twilioquest-code/shouldWater.js b/Javascript/week2/code/solution/twilioquest-code/shouldWater.js deleted file mode 100644 index ced502cf..00000000 --- a/Javascript/week2/code/solution/twilioquest-code/shouldWater.js +++ /dev/null @@ -1,7 +0,0 @@ -const lifeStatus = process.argv[2]; -const dryLevel = process.argv[3]; -const dryNumber = Number(dryLevel); - -if (lifeStatus === '0' && dryNumber > 10) { - console.log("WATER"); -} \ No newline at end of file diff --git a/Javascript/week2/code/solution/twilioquest-code/sortOrder.js b/Javascript/week2/code/solution/twilioquest-code/sortOrder.js deleted file mode 100644 index ce168261..00000000 --- a/Javascript/week2/code/solution/twilioquest-code/sortOrder.js +++ /dev/null @@ -1,10 +0,0 @@ -const firstWord = process.argv[2].toLowerCase(); -const secondWord = process.argv[3].toLowerCase(); - -if (firstWord < secondWord) { - console.log(-1); -} else if (firstWord > secondWord) { - console.log(1); -} else { - console.log(0); -} \ No newline at end of file diff --git a/Javascript/week2/code/solution/twilioquest-code/treeLifeDetector.js b/Javascript/week2/code/solution/twilioquest-code/treeLifeDetector.js deleted file mode 100644 index f1ee19eb..00000000 --- a/Javascript/week2/code/solution/twilioquest-code/treeLifeDetector.js +++ /dev/null @@ -1,7 +0,0 @@ -const treeStatus = process.argv[2]; - -if (treeStatus === '0') { - console.log("alive"); -} else { - console.log("other"); -} \ No newline at end of file diff --git a/Javascript/week2/issues/2.1-romancalc.md b/Javascript/week2/issues/2.1-romancalc.md deleted file mode 100644 index c18016ce..00000000 --- a/Javascript/week2/issues/2.1-romancalc.md +++ /dev/null @@ -1,99 +0,0 @@ -## Roman Calculator - -*For this assignment, you will follow the instructions and complete a task showing your knowledge of the subject at the end. If at any moment you need help, feel free to contact your TAs.* - -You're a time traveller who is about to go back in time and want to build a bunch of cool devices for the people back in the day. You decide to build a basic calculator since math is the coolest subject in the world and you want to help the Romans become really efficient in their calculations. - -### :airplane: Phase 1 - -Create a file called romancalc.js - -**Collecting user input from command line in JS** - -Create a function called get_args that, quite literally, gets arguments from the user and returns the arguments. The user will provide these arguments in the command line when they run their code: ``` node romancalc.js 5 x 4 ```. For the first phase, we will only focus on getting and storing those arguments for future use. - -Knowing that functions can only return one element, you want to store these arguments in an array. You can then return the array so that other functions calling get_args can have access to the the arguments. - -### :pencil: Commenting your Code - -Use in line comments to explain how your code works. Commenting your code helps ensure that you understand what is happening, and helps the code reviewer read through your code easily. For example: - -**Great example:** - -``` -var i; // Initialize a variable -for (i = 0; i < nums.length; i++) { // Initialize a for loop that iterates from 0 to length of the nums array - nums[i]+5; // At every iteration, add the i-th integer in the nums array to the text variable -} // End of loop - -``` - -When you start writing more code (200+ lines) you will want to do the next example. For this course, your code should not extend past 50-100 lines and we want to use your comments to see how well you understand the concepts and language, so it's better to use the previous example. - -**Okay example:** - -``` -// This code uses a for loop to iterate through the entire nums array and add 5 to each element -var i; -for (i = 0; i < nums.length; i++) { - nums[i]+5; -} - -``` - -**Don't do this:** - -``` -// Add 5 to all values in nums array -var i; -for (i = 0; i < nums.length; i++) { - nums[i]+5; -} - -``` - -### :red_car: Running your Code - -1. Save your file -2. Make sure you're in the same directory in which you saved your romancalc.js file -3. To run your fancy new program, type: `node romancalc.js` in terminal with any additional arguments - -### :pencil2: Testing - -1. Add ```let op = get_args();``` to the end of your code to check that the get_args function returns an array -2. Add the following to confirm if your array contains the right arguments -- ```console.log("The first operand is: ", op[0]);``` -- ```console.log("The second operand is: ", op[2]);``` -- ```console.log("The operator is: ", op[1]);``` - -Run ```node romancalc.js a b c``` - -**Test Case 1:** - -**Input:** ```node romancalc.js 4.4 / 4``` - -**Output:** - -```c -The first operand is: 4.4 -The second operand is: 4 -The operator is: / -``` - -**Test Case 2:** - -**Input:** ```node romancalc.js 2 r to``` - -**Output:** - -```c -The first operand is: 2 -The second operand is: to -The operator is: r -``` - -### βœ… Submit - -**Task 1: Complete a function that gets and stores user input!** - -Commit a file called romancalc.js diff --git a/Javascript/week2/issues/2.2-romancalc.md b/Javascript/week2/issues/2.2-romancalc.md deleted file mode 100644 index 83432b82..00000000 --- a/Javascript/week2/issues/2.2-romancalc.md +++ /dev/null @@ -1,124 +0,0 @@ -## Roman Calculator - -*For this assignment, you will follow the instructions and complete a task showing your knowledge of the subject at the end. If at any moment you need help, feel free to contact your TAs.* - -You're a time traveller who is about to go back in time and want to build a bunch of cool devices for the people back in the day. You decide to build a basic calculator since math is the coolest subject in the world and you want to help the romans become really efficient in their calculations. - -### :airplane: Phase 2 - -Continue working in romancalc.js - -**Building a basic calculator** - -Create a function called calculate() that calculates using operands and operand from the user and returns the result. - -1. Initialize variables with the second, third, and fourth arguments from user input. You have already created a function called get_args(), which you can use in calculate to get the operators and operand. -2. Initialize variable to hold result of operations. -3. Use conditions to determine what the operation is from the user input and calculate the result: - - Addition: + - - Subtraction: - - - Multiplication: x - - Division: / - - Exponents: ^ - - Modulus: % -4. Return the result (don't print them other than for testing). - -**Assumptions:** - -- Assume that the operator will always be one of the above -- Getting * from the command line might cause an error so you can assume that multiplication will be represented with an 'x' - -**Challenge** - -This calculator is really simple and doesn't handle error management very well. Try adding some error messages for the user so they know when their input in invalid. Consider what valid input should look like. - -Can you think of any more operations you want to implement? Try adding them! - -Consider developing your calculator to handle more complicated equations. - -**Hints** - -- Build the calculator with temporary variable that you declare in the code and think about user input after you have the basic functionality working. -- Multiplication and exponents do not use 'x' or '^' in JS - you will need to research the correct operator to make the calculations - -### :pencil: Commenting your Code - -Use in line comments to explain how your code works. Commenting your code helps ensure that you understand what is happening, and helps the code reviewer read through your code easily. For example: - -**Great example:** - -``` -var i; // Initialize a variable -for (i = 0; i < nums.length; i++) { // Initialize a for loop that iterates from 0 to length of the nums array - nums[i]+5; // At every iteration, add the i-th integer in the nums array to the text variable -} // End of loop - -``` - -When you start writing more code (200+ lines) you will want to do the next example. For this course, your code should not extend past 50-100 lines and we want to use your comments to see how well you understand the concepts and language, so it's better to use the previous example. - -**Okay example:** - -``` -// This code uses a for loop to iterate through the entire nums array and add 5 to each element -var i; -for (i = 0; i < nums.length; i++) { - nums[i]+5; -} - -``` - -**Don't do this:** - -``` -// Add 5 to all values in nums array -var i; -for (i = 0; i < nums.length; i++) { - nums[i]+5; -} - -``` - -### :red_car: Running your Code - -1. Save your file -2. Make sure you're in the same directory in which you saved your romancalc.js file -3. To run your fancy new program, type: `node romancalc.js` in terminal with any additional arguments - -### :pencil2: Testing - -1. Add ```console.log(calculate());``` to the end of your code - -Run ```node romancalc.js a b c``` - -**Test Cases:** - -**Input:** ```node romancalc.js 98 + 94``` - -**Output: 192** - -**Input:** ```node romancalc.js 22 - 95``` - -**Output: -73** - -**Input:** ```node romancalc.js 53 x 48``` - -**Output: 2544** - -**Input:** ```node romancalc.js 25 / 84``` - -**Output: 0.2976190476190476** - -**Input:** ```node romancalc.js 5 ^ 4``` - -**Output: 625** - -**Input:** ```node romancalc.js 143 % 7``` - -**Output: 3** - -### βœ… Submit - -**Phase 2: Complete a calculator that can do basic math equations!** - -Commit a file called romancalc.js diff --git a/Javascript/week2/issues/2.3-romancalc.md b/Javascript/week2/issues/2.3-romancalc.md deleted file mode 100644 index ca62e2ff..00000000 --- a/Javascript/week2/issues/2.3-romancalc.md +++ /dev/null @@ -1,87 +0,0 @@ -## Roman Calculator - -*For this assignment, you will follow the instructions and complete a task showing your knowledge of the subject at the end. If at any moment you need help, feel free to contact your TAs.* - -You're a time traveller who is about to go back in time and want to build a bunch of cool devices for the people back in the day. You decide to build a basic calculator since math is the coolest subject in the world and you want to help the romans become really efficient in their calculations. - -### :airplane: Phase 3 - -Continue working in romancalc.js - -**Converting from Roman Numerals to Integers** - -You have now successfully created a calculator and a way to get the users's input. The issue is that since you're taking this calculator to the Romans, your calculator needs to be able to work with Roman Numerals. - -Create a function called romanToInt() that takes a string of characters as input and converts it to an integer, and returns the converted integer. - -### :pencil: Commenting your Code - -Use in line comments to explain how your code works. Commenting your code helps ensure that you understand what is happening, and helps the code reviewer read through your code easily. For example: - -**Great example:** - -``` -var i; // Initialize a variable -for (i = 0; i < nums.length; i++) { // Initialize a for loop that iterates from 0 to length of the nums array - nums[i]+5; // At every iteration, add the i-th integer in the nums array to the text variable -} // End of loop - -``` - -When you start writing more code (200+ lines) you will want to do the next example. For this course, your code should not extend past 50-100 lines and we want to use your comments to see how well you understand the concepts and language, so it's better to use the previous example. - -**Okay example:** - -``` -// This code uses a for loop to iterate through the entire nums array and add 5 to each element -var i; -for (i = 0; i < nums.length; i++) { - nums[i]+5; -} - -``` - -**Don't do this:** - -``` -// Add 5 to all values in nums array -var i; -for (i = 0; i < nums.length; i++) { - nums[i]+5; -} - -``` - -### :red_car: Running your Code - -1. Save your file -2. Make sure you're in the same directory in which you saved your romancalc.js file -3. To run your fancy new program, type: `node romancalc.js` in terminal with any additional arguments - -### :pencil2: Testing - -Add ```console.log(romanToInt("process.argv[2]"));``` to the end of your code and run ```node romancalc.js a``` where 'a' is the Roman Numeral you want to convert - -**Test Case 1:** - -**Input:** ```node romancalc.js 4``` - -**Output: NaN (error)** - -**Test Case 1:** - -**Input:** ```node romancalc.js IV``` - -**Output: 4** - -**Test Case 1:** - -**Input: `**``node romancalc.js CMXXVII``` - -**Output: 927** - -### βœ… Submit - -**Phase 3: Complete a function to convert Roman Numerals to Integers** - -Commit a file called romancalc.js diff --git a/Javascript/week2/issues/2.4-romancalc.md b/Javascript/week2/issues/2.4-romancalc.md deleted file mode 100644 index 9dd70f74..00000000 --- a/Javascript/week2/issues/2.4-romancalc.md +++ /dev/null @@ -1,87 +0,0 @@ -## Roman Calculator - -*For this assignment, you will follow the instructions and complete a task showing your knowledge of the subject at the end. If at any moment you need help, feel free to contact your TAs.* - -You're a time traveller who is about to go back in time and want to build a bunch of cool devices for the people back in the day. You decide to build a basic calculator since math is the coolest subject in the world and you want to help the romans become really efficient in their calculations. - -### :airplane: Phase 4 - -Continue working in romancalc.js - -**Converting from Integers to Roman Numerals** - -If you get user input in the form of Roman Numerals, you will need to convert them into integers to do the calculations. But once the calculations are done, you will want to convert them back into Roman Numerals so that the user can read them. - -Create a function called intToRoman() that takes an integer as input and converts it to Roman Numerals, and returns the converted Roman Numerals. - -### :pencil: Commenting your Code - -Use in line comments to explain how your code works. Commenting your code helps ensure that you understand what is happening, and helps the code reviewer read through your code easily. For example: - -**Great example:** - -``` -var i; // Initialize a variable -for (i = 0; i < nums.length; i++) { // Initialize a for loop that iterates from 0 to length of the nums array - nums[i]+5; // At every iteration, add the i-th integer in the nums array to the text variable -} // End of loop - -``` - -When you start writing more code (200+ lines) you will want to do the next example. For this course, your code should not extend past 50-100 lines and we want to use your comments to see how well you understand the concepts and language, so it's better to use the previous example. - -**Okay example:** - -``` -// This code uses a for loop to iterate through the entire nums array and add 5 to each element -var i; -for (i = 0; i < nums.length; i++) { - nums[i]+5; -} - -``` - -**Don't do this:** - -``` -// Add 5 to all values in nums array -var i; -for (i = 0; i < nums.length; i++) { - nums[i]+5; -} - -``` - -### :red_car: Running your Code - -1. Save your file -2. Make sure you're in the same directory in which you saved your romancalc.js file -3. To run your fancy new program, type: `node romancalc.js` in terminal with any additional arguments - -### :pencil2: Testing - -Add ```console.log(intToRoman("process.argv[2]"));``` to the end of your code and run ```node romancalc.js a``` where 'a' is the integer you want to convert - -**Test Case 1:** - -**Input:** ```node romancalc.js M``` - -**Output: NaN (error)** - -**Test Case 1:** - -**Input:** ```node romancalc.js 4``` - -**Output: IV** - -**Test Case 1:** - -**Input: `**``node romancalc.js 927``` - -**Output: CMXXVII** - -### βœ… Submit - -**Phase 4: Complete a function to convert integers to Roman Numerals** - -Commit a file called romancalc.js diff --git a/Javascript/week2/issues/2.5-romancalc.md b/Javascript/week2/issues/2.5-romancalc.md deleted file mode 100644 index b37ba5da..00000000 --- a/Javascript/week2/issues/2.5-romancalc.md +++ /dev/null @@ -1,95 +0,0 @@ -## Roman Calculator - -*For this assignment, you will follow the instructions and complete a task showing your knowledge of the subject at the end. If at any moment you need help, feel free to contact your TAs.* - -You're a time traveller who is about to go back in time and want to build a bunch of cool devices for the people back in the day. You decide to build a basic calculator since math is the coolest subject in the world and you want to help the romans become really efficient in their calculations. - -### :airplane: Phase 5 - -Continue working in romancalc.js - -**Before starting, add this function to the top of your code:** - -```function isNumber(n) { return /^-?[\d.]+(?:e-?\d+)?$/.test(n); }``` this function returns true (0) for input that is a number and false for anything else, and will help you identify if your user input is an integer or a Roman Numeral. - -**Putting it all together** - -Now that you have your functions all set, all you have to do it put them together: - -- Move your functions from phases 3 and 4 above the get_args function of the file (so that the functions can be called later) -- Edit your get_args function so that it converts any Roman Numeral inputs into integers before storing (you can use the isNumber function here) -- Always display both the integer and Roman Numeral version of the results for accessibility - -### :pencil: Commenting your Code - -Use in line comments to explain how your code works. Commenting your code helps ensure that you understand what is happening, and helps the code reviewer read through your code easily. For example: - -**Great example:** - -``` -var i; // Initialize a variable -for (i = 0; i < nums.length; i++) { // Initialize a for loop that iterates from 0 to length of the nums array - nums[i]+5; // At every iteration, add the i-th integer in the nums array to the text variable -} // End of loop - -``` - -When you start writing more code (200+ lines) you will want to do the next example. For this course, your code should not extend past 50-100 lines and we want to use your comments to see how well you understand the concepts and language, so it's better to use the previous example. - -**Okay example:** - -``` -// This code uses a for loop to iterate through the entire nums array and add 5 to each element -var i; -for (i = 0; i < nums.length; i++) { - nums[i]+5; -} - -``` - -**Don't do this:** - -``` -// Add 5 to all values in nums array -var i; -for (i = 0; i < nums.length; i++) { - nums[i]+5; -} - -``` - -### :red_car: Running your Code - -1. Save your file -2. Make sure you're in the same directory in which you saved your romancalc.js file -3. To run your fancy new program, type: `node romancalc.js` in terminal with any additional arguments - -### :pencil2: Testing - -Add ```console.log(intToRoman("process.argv[2]"));``` to the end of your code and run ```node romancalc.js a``` where 'a' is the integer you want to convert - -**Test Case 1:** - -**Input:** ```node romancalc.js 4 + X``` - -**Output: 14, XIV** - -**Test Case 1:** - -**Input:** ```node romancalc.js 4732 / 34``` - -**Output: 139.1764705882353** - -(There will be no Roman Numeral for this) - -**Test Case 1:** - -**Input: `**``node romancalc.js CCCXCIII % LXXVII``` - -**Output: 8, VIII** - -### βœ… Submit - -**Phase 5: Complete a function to convert integers to Roman Numerals** - -Commit a file called romancalc.js diff --git a/Javascript/week3/issues/3.1-recursion-intro.md b/Javascript/week3/issues/3.1-recursion-intro.md deleted file mode 100644 index 2d9ccdbb..00000000 --- a/Javascript/week3/issues/3.1-recursion-intro.md +++ /dev/null @@ -1,112 +0,0 @@ -# Introduction to Recursion - -*This assignment will demonstrate the basics of recursion, and ask you to create a recursive function of your own. If at any moment you need help, feel free to contact your TAs.* - -In English, the term "*recursive*" means something is "*characterized by recurrence or repetition*." Many natural processes in the world are recursive. As an example, start with an equilateral triangle, and replace the middle 1/3rd of each side by another equilateral triangle. Continue this process over and over until you begin to see something like a snowflake. This is called a [Koch snowflake](http://en.wikipedia.org/wiki/Koch_snowflake). - -![Koch snowflake](https://upload.wikimedia.org/wikipedia/commons/f/fd/Von_Koch_curve.gif) - -**Recursion** is the process in which a function calls itself directly or indirectly. A function is said to be **recursive** if it calls itself. Let's look at an example. - -```javascript -function HelloWorld(count) { - if (count < 1) return - print("Hello World!") - HelloWorld(count - 1) -} -``` - -Let's trace through an example of calling this function. We'll call `HelloWorld(5)`. - -```javascript -HelloWorld(5) -// count of 5 is not less than 1. Print Hello World. Call HelloWorld(4). -// count of 4 is not less than 1. Print Hello World. Call HelloWorld(3). -// count of 3 is not less than 1. Print Hello World. Call HelloWorld(2). -// count of 2 is not less than 1. Print Hello World. Call HelloWorld(1). -// count of 1 is not less than 1. Print Hello World. Call HelloWorld(0). -// count of 0 IS less than 1. Return. -``` - -Notice how the command `print("Hello World!")` is run 5 times in total throughout this recursive call. Thus, our output should look something like this: - -```bash -Hello World! -Hello World! -Hello World! -Hello World! -Hello World! -``` - -You may wonder why we don't simply use a `for` loop, in which case your argument would be completely valid! However, in this case, we used a relatively simple function in order to demonstrate how recursion works. Where recursion truly shines is in the more complex problems. - -Let's take a look at the Fibonacci numbers. In mathematics, the **Fibonacci numbers** form a sequence called the **Fibonacci sequence**, such that each number is the sum of the two preceding ones, starting from 0 and 1. What's cool is that the Fibonacci sequence uses zero-based indexing, which lends itself very well to most programming languages. Here is the beginning of the Fibonacci sequence: - -![fibonacci sequence](https://latex.codecogs.com/svg.latex?0,%201,%201,%202,%203,%205,%208,%2013,%2021,%2034,%2055,%2089,%2014,...) - -How can we use code to find the *n*th Fibonacci number? For example, we would input the number 3 and the program should output 2, the 3rd Fibonacci number (remember that the Fibonacci sequence uses zero-based indexing!). It turns out that recursion lends itself very well to this particular problem. - -```javascript -function findFibonacci(n) { - if (n < 2) return n - return findFibonacci(n-1) + findFibonacci(n-2) -} -``` - - Let's trace through the code using an example of ``findFibonacci(3)``. - -```javascript -findFibonacci(3) -// n of 3 is not less than 2. return findFibonacci(2) + findFibonacci(1) - // findFibonacci(2): n of 2 is not less than 2. return findFibonacci(1) + findFibonacci(0) - // findFibonacci(1): n of 1 IS less than 2. return n (which is 1) - // findFibonacci(0): n of 0 IS less than 2. return n (which is 0) - // Thus, findFibonacci(1) + findFibonacci(0) = 1 + 0 = 1 - // findFibonacci(1): n of 1 IS less than 2. return n (which is 1) - // Thus, findFibonacci(2) + findFibonacci(1) = 1 + 1 = 2 -Output: 2 -``` - -Take some time to run through the process above and make sure it makes sense. There is something we should take care to note: notice how we run the function `findFibonacci(1)` twice! This actually becomes *incredibly* burdensome once we use larger numbers, and we can end up running the same functions hundreds, even thousands of times - and there is most definitely a faster way to compute the Fibonacci numbers. However, this is beyond the scope of the course, and we utilized this function just to show an example of what recursion can look like. - -Pay attention to how our recursive functions have been structured so far. We first always identify **a base case** such that our recursive calls will always be stopped at some point. In `findFibonacci(n)`, our base case was any *n* less than 2, to mark the first two numbers of the Fibonacci sequence: 0 and 1. In `Hello World`, our base case was `count < 1` i.e. whenever our count got down to 0. This makes sense because once our count comes down to zero, we don't want to print any more `Hello World!`s. Thus, our first recommendation for writing recursive functions is to **always identify the base case first!** - -![base case](https://miro.medium.com/max/2800/1*JpCAqm8HdKuBhyRs9NYCOg.png) - -Your next step should then to make the recursive calls. This skill can only be polished with more practice, so don't worry if you don't get it the first time. Our best advice here is to **trust that your code works**. - -![trust and believe](https://media4.giphy.com/media/QM6TiqlweEa7MBJhyG/giphy.gif?cid=ecf05e47xrzp72ck8kixabfe9lz1noiid4ih8b1ust1v5m68&rid=giphy.gif) - -Hopefully you now have a sense of what recursion is, and a vague idea of how to construct a recursive function. Don't worry if you're struggling a little bit with thinking recursively - it will start coming naturally with more and more practice. If you're looking to try out a few more problems by yourself, [this](https://codingbat.com/java/Recursion-1) is a great website with a list of incrementally harder recursion problems to solve! Although it only compiles Java (not JavaScript), you can use Node to run your code locally on your machine instead. Moreover, in the website, you can type a return statement in the given code box and click the `Go` button to find many more test cases to ensure your program runs correctly. - -**πŸš— Challenge** - -To complete this assignment, create a recursive function that returns the factorial of an integer *n* (without using a for loop!). Recall that the [factorial](https://en.wikipedia.org/wiki/Factorial#:~:text=In%20mathematics%2C%20the%20factorial%20of,convention%20for%20an%20empty%20product.) of a number n is denoted by *n!*, where: - -![factorial definition](https://latex.codecogs.com/svg.latex?n!=n%20\cdot%20(n-1)\cdot%20(n-2)\cdot%20(n-3)\cdot...\cdot3\cdot2\cdot1) - -For example, 5! = 5 x 4 x 3 x 2 x 1 = 120. - -Hint: Identify a base case first! Then move onto the recursive call. Please contact your TA if you need any help at all! - -### ✏️ Testing - -Once you have your function set up, it's time to test it out! Here are a few test cases: - -| Function Call | Output | -| ------------- | --------- | -| factorial(1) | 1 | -| factorial(2) | 2 | -| factorial(3) | 6 | -| factorial(4) | 24 | -| factorial(5) | 120 | -| factorial(6) | 720 | -| factorial(7) | 5040 | -| factorial(8) | 40320 | -| factorial(12) | 479001600 | - -Here is a [list of 100 factorials](https://www.mymathtables.com/numbers/100-factorial-tables-chart.html) in case you'd like to check more. - -### βœ… Submit - -Commit a file called factorial.js with your recursive factorial function! diff --git a/Javascript/week3/issues/3.2-javascriptcanvas.md b/Javascript/week3/issues/3.2-javascriptcanvas.md deleted file mode 100644 index 28f3e517..00000000 --- a/Javascript/week3/issues/3.2-javascriptcanvas.md +++ /dev/null @@ -1,62 +0,0 @@ -## Recursive Art - -*For this assignment, you will follow the instructions and complete a task showing your knowledge of the subject at the end. If at any moment you need help, feel free to contact your TAs.* - -You've received some signals from aliens that decode to result in intricate graphics. These images have patterns that seem to repeat themselves and represent mathematical concepts which appear all around earth in nature. You have decided to recreate these messages in order to resume communication with the extraterrestrials. -### :airplane: Phase 2 - -Create a new file named drawing.js - -**Learning how to draw in JavaScript** - -*In your project for this week, you will mainly focus on creating a function that will draw **one** shape continuously, so keep these handy!* - -Shapes: -* Rectangle: `rect(x, y, w, h)` -* Ellipse: `ellipse(x, y, w, h)` -* Triangle: `triangle(x1, y1, x2, y2, x3, y3)` -* Line: `line(x1, y1, x2, y2)` -* Point: `point(x, y)` -* Arc: `arc(x, y, w, h, start, stop)` -* Bezier: `bezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2)` -* Quadrilateral: `quad(x1, y1, x2, y2, x3, y3, x4, y4)` -* Image: `image(image, x, y, width*, height*)` - -*For more complex shapes and examples, visit [here](https://www.khanacademy.org/computing/computer-science/algorithms/recursive-algorithms/pp/project-recursive-art)* (Thank you Khan!) - -Want to be :sparkles:fancy:sparkles:? Try changing the colors: -* `background(r, g, b)` (Set background color) -* `fill(r, g, b)` (Set fill color) -* `noFill()` (Stop filling in shapes) -* `stroke(r, g, b)` (Set the outline color for shapes) -* `strokeWeight(thickness)` (Alter thickness of strokes) -* `noStroke()` (Stop outlining for shapes) -* `color(r, g, b)` (Store a color in a variable) -* `blendColor(c1, c2, MODE)` (Blend two colors) -* `lerpColor(c1, c2, amount)` (Using 2 colors, find one in between) - -Randomizing Your Drawing -* Using `Math.random()*n` gives you a random number in the range of 0 and n. -> Tip: Try manipulating the number in some way to incorporate it into the parameter of a shape or color - -**Challenge** - -To practice implementing the concept of recursion in JavaScript art, start by creating a drawing of an alien (doesn't have to be perfect!). This drawing will be unique each separate time you run the program. - -### :red_car: Running your Code - -*Since we are focusing on pure JavaScript and this task requires HTML to run, we are going to be borrowing Khan's website to display our artwork.* -1. Go to this [website](https://www.khanacademy.org/computer-programming/new/pjs) -2. Write your code in the provided area -3. If your code doesn't have output that will be different everytime, the drawing will update whenever you change the code -3. If you implement something like randomization, a "restart" button will appear to run it multiple times - -### :pencil2: Testing - -Time to check if you are able to create a unique :alien: everytime, press "restart" and see the face change! - -### βœ… Submit - -**Phase 2: Complete a program that draws a unique alien** - -Commit a file called drawing.js diff --git a/Javascript/week3/issues/3.3-recursionexample.md b/Javascript/week3/issues/3.3-recursionexample.md deleted file mode 100644 index 9e9c82fd..00000000 --- a/Javascript/week3/issues/3.3-recursionexample.md +++ /dev/null @@ -1,96 +0,0 @@ -## Recursive Art - -*For this assignment, you will follow the instructions and complete a task showing your knowledge of the subject at the end. If at any moment you need help, feel free to contact your TAs.* - -You've received some signals from aliens that decode to result in intricate graphics. These images have patterns that seem to repeat themselves and represent mathematical concepts which appear all around earth in nature. You have decided to recreate these messages in order to resume communication with the extraterrestrials. -### :airplane: Phase 3 - -For this lesson, we're just going to be taking a look at an example of recursive art to get your gears running. - -**:eyes: Taking a peek at an example** - -[See what our shell looks like](https://www.khanacademy.org/computer-programming/drawing-a-shell-through-recursion/5014901340454912) - -### :question: What's happening? - -**The key to recursion is `drawShape()` in this program** - -Before we get into how this drawing is done with the concept, we'll go over what's happening. - -* The *very first* time the function is called, x = 200, y = 200, size = 360, and orientation = false. -```js -drawShape(200, 200, 360, false); -``` - -* In the function, the parameter `orientation` determines which way the arc should face (up or down). In this case, it's false, so we are drawing an arc face down. -```js - // start and stop degrees of arc - var start = 0; - var stop = 180; - - // if arc is right side up, switch start and stop so arc becomes right side up - if (orientation) { - start = 180; - stop = 360; - } -``` - -* We then draw our first arc with the parameters called with the function (x = 200, y = 200, size = 360, and orientation = false) -```js - // draw arc - arc(x, y, size, size, start, stop); -``` - -* The variable `orientation` also dictates where the arc should begin to draw: -```js - if (orientation) { - x = x + scale * size; - } else { - x = x - scale * size; - } -``` - -* Next we see `var scale = 0.085;`, which is a key component in the recursion calculation. This is what causes the arcs to get smaller as we go deeper and deeper. -* And that leads into our the key calculation! For the arcs to become spirals, if orientation is `true` (or the arc is facing up) it will move the pen to the right. If orientation is `false` (or the arc is facing down) the pen will start further to the left instead. This allows the shell to spiral and get smaller. -> Keep in mind, these new calculated values will be applied the next time the function is called. In additional to different x values, we will also make the radius smaller by assigning a new value to `size` -```js - // adjust x coordinate of next arc depending on orientation of arc - if (orientation) { - x = x + scale * size; - } else { - x = x - scale * size; - } -``` -* In order for the arc to stay centered *and* decrease in size, we also need to calculate a `newSize` value. `var newSize = size/1.2;` -* Lastly, to continue the recursion we need to call our `drawShape()` function again, but with some catches. -```js - if (newSize >= 4) { - drawShape(x, y, newSize, !orientation); - } -``` -> 1. Since recursion is not an infinite loop, we want the function to stop being called once the size is less than 4 -> 2. We want to flip the boolean of orientation so that if it previously drew an arc facing down, we will now draw one facing up. - -**And that's it! `drawShape()` will continue to be called, arcs will continue to be drawn, and new values will be calculated until the size becomes less than 4.** - - -### :pencil2: Requirements - -In the next part, you're going to be creating *your own* recursive art, but we'll be adding some requirements: -1) Have a base case (*This is the "endpoint" where the calculation terminates or stops*) - * Remember: Recursion is **not** an infinite loop! -2) Have a rule that causes the calculation continue or go deeper and deeper (continues the recursion) -3) For fun and **not demonstrated in the example**: the artwork must be randomized, meaning that a characteristic (can be size, color, length, or shape) is changed everytime the code is run - -*These requirements are exemplified in the example above, so let's talk a little about how the code incorporates them* - -1) The base case in the example is when the size is divided by 1.2 so many times that it becomes less than 4. *This is when the calculation terminates and the function is not called anymore* -2) The rule that causes the calculation to go deeper is the fact that function will need to be continuously called within eachother until size is less than 4. - -### βœ… Submit - -**Time to do some research: Find *one* example of recursion in nature and explain how *one* of the requirements applies.** - -![recursive leaf](https://qph.fs.quoracdn.net/main-qimg-391b16b1db97d8d518a0abf46cf725d2) - -Comment your findings to move on and start on your artwork! :mag: diff --git a/Javascript/week3/issues/3.4-creatingart.md b/Javascript/week3/issues/3.4-creatingart.md deleted file mode 100644 index 929e3ce8..00000000 --- a/Javascript/week3/issues/3.4-creatingart.md +++ /dev/null @@ -1,44 +0,0 @@ -## Recursive Art - -*For this assignment, you will follow the instructions and complete a task showing your knowledge of the subject at the end. If at any moment you need help, feel free to contact your TAs.* - -You've received some signals from aliens that decode to result in intricate graphics. These images have patterns that seem to repeat themselves and represent mathematical concepts which appear all around earth in nature. You have decided to recreate these messages in order to resume communication with the extraterrestrials. -### :airplane: Phase 4 - -Create a new file named artproject.js - -**Creating your own Recursive Art** - -It's finally time to send the aliens your own personalized art for them to decipher... We just have the 3 requirements in order to make communication go smoothly. - -Here are some examples that you can take inspiration from, but try to keep yours original! -* [Ferns](https://www.khanacademy.org/computer-programming/spin-off-of-project-recursive-art/4629064758460416) -* [Colorful Tree](https://www.khanacademy.org/computer-programming/spin-off-of-project-recursive-art/5247010782445568) -* [Geometric](https://www.khanacademy.org/computer-programming/spin-off-of-project-recursive-art/4677141495414784) - -*Find more [here](https://www.khanacademy.org/computer-programming/project-recursive-art/6665781324021760) under "Spinoffs"* - -**Challenge** - -Draw anything (with common sense) utilizing recursion. Meet these 3 requirements: -1) Have a base case (*This is the "endpoint" where the calculation terminates or stops*) - * Remember: Recursion is **not** an infinite loop! -2) Have a rule that causes the calculation continue or go deeper and deeper (continues the recursion) -3) For fun: the artwork must be randomized, meaning that a characteristic (can be size, color, length, or shape) is changed everytime the code is run - -### :red_car: Running your Code - -*Since we are focusing on pure JavaScript and this task requires HTML to run, we are going to be borrowing Khan's website to display our artwork.* -1. Go to this [website](https://www.khanacademy.org/computer-programming/new/pjs) -2. Write your code in the provided area -3. With randomization, a "restart" button will appear to run it multiple times - -### :pencil2: Testing - -Go ahead and press "restart" as many times as you wish to view your recursive art. Make sure it meets those 3 requirements! - -### βœ… Submit - -**Phase 2: Complete a program that creates a randomized piece of art with recursion!** - -Commit a file called artproject.js diff --git a/Javascript/week4/issues/4.1-project.md b/Javascript/week4/issues/4.1-project.md deleted file mode 100644 index eeeca1fe..00000000 --- a/Javascript/week4/issues/4.1-project.md +++ /dev/null @@ -1,15 +0,0 @@ -### :rocket: Project! - -#### :tada: Congratulations! :tada: You’ve reached the final week of Camp Twilio. Now let’s put your experience from time traveling :alarm_clock: and communicating with aliens :alien: to the ultimate test. - -For your final project, you have complete :sparkles:creative freedom:sparkles: to essentially create whatever your heart’s desire isβ€”with a few catches. To ensure that you’ve learned a lesson from your adventure through the cosmos, there are a few concepts you need to make sure you include in your creation. - -* :arrow_right: **Incorporate JavaScript arrays, loops, conditional statements, and recursion!** -* :arrow_right: **Keep your inputs and outputs based in the console like we’ve been doing these past 3 weeks.** - -If you’re having trouble brainstorming :brain: the perfect project idea, take a look at these examples and talk with your mentors. Don’t be afraid to reach out to them as well if you have questions about how to integrate those concepts. - -> Try creating... -> 1. [Text adventure game](https://github.com/okaybenji/text-engine) -> 2. [Tic Tac Toe](https://dev.to/shriji/game-on-console-log-5cbk) -> 3. Try Googling "Javascript console.log() projects"