├── .gitignore ├── unit-testing ├── exercises │ ├── tests │ │ ├── RPS.test.js │ │ └── checkFive.test.js │ ├── checkFive.js │ ├── package.json │ └── RPS.js ├── studio │ ├── index.js │ ├── tests │ │ └── launchcode.test.js │ └── package.json └── chapter-examples │ ├── transmission-processor │ ├── tests │ │ └── processor.test.js │ └── package.json │ ├── hello-jest │ ├── hello.js │ ├── package.json │ └── tests │ │ └── hello.test.js │ └── palindrome-example │ ├── palindrome.js │ └── package.json ├── fetch ├── studio │ ├── script.js │ ├── style.css │ └── index.html └── chapter-examples │ └── fetching-data │ ├── fetch-weather-part-1.html │ ├── fetch-weather-part-2.html │ └── fetch-weather-part-3.html ├── terminal-commands └── launchcode_courses │ ├── data_analysis │ ├── cities.sql │ ├── lakes.json │ └── final_project │ │ └── .empty_file.txt │ └── lc_101 │ └── unit_1 │ ├── styles.css │ ├── about_me.html │ └── hello_world.js ├── css └── exercises │ ├── styles.css │ ├── script.js │ └── index.html ├── user-input-with-forms ├── exercises │ ├── script.js │ ├── style.css │ └── index.html ├── chapter-examples │ ├── checkbox-inputs │ │ ├── script.js │ │ ├── style.css │ │ └── index.html │ ├── form-validation │ │ ├── script.js │ │ ├── style.css │ │ └── index.html │ ├── form-submission.html │ └── form-post.html └── studio │ └── index.html ├── dom-and-events ├── exercises │ ├── style.css │ ├── script.js │ └── index.html └── studio │ ├── scripts.js │ ├── LaunchCode_rocketline_white.png │ ├── styles.css │ └── index.html ├── data-and-variables ├── chapter-examples │ ├── bruces-beard.js │ ├── type-of.js │ ├── readline-sync.js │ ├── readline-greeting-program.js │ ├── more-on-numbers.js │ ├── more-on-strings.js │ ├── critical-input-detail.js │ ├── type-conversion.js │ └── package.json └── exercises │ └── data-and-variables-exercises.js ├── errors-and-debugging ├── chapter-examples │ ├── SyntaxErrors.js │ ├── Syntax-Highlighting.js │ └── degrees-c-to-k.js └── exercises │ ├── Debugging1stSyntaxError.js │ ├── DebuggingRuntimeErrors1.js │ ├── DebuggingRuntimeErrors2.js │ ├── DebuggingSyntaxErrors2.js │ ├── DebuggingLogicErrors1.js │ ├── DebuggingLogicErrors5.js │ ├── DebuggingLogicErrors2.js │ ├── DebuggingLogicErrors3.js │ └── DebuggingLogicErrors4.js ├── exceptions ├── chapter-examples │ ├── throw-default-error.js │ ├── try-catch │ │ ├── package.json │ │ └── try-catch.js │ └── finally │ │ ├── package.json │ │ └── finally.js └── exercises │ ├── divide.js │ └── test-student-labs.js ├── functions ├── try-it │ ├── sayHello.js │ ├── isPalindrome.js │ ├── reverse.js │ └── printMessage.js └── studio │ └── studio-functions.js ├── modules ├── exporting-modules │ ├── index.js │ └── practiceExports.js └── exercises │ ├── randomSelect.js │ ├── package.json │ ├── ScoreCalcs │ └── averages.js │ ├── display.js │ └── index.js ├── arrays ├── exercises │ ├── package.json │ ├── part-one-arrays.js │ ├── part-three-arrays.js │ ├── part-five-arrays.js │ ├── part-four-arrays.js │ ├── part-two-arrays.js │ └── part-six-arrays.js └── studio │ ├── package.json │ ├── array-string-conversion │ ├── index.js │ ├── package.json │ ├── spec │ │ └── array-testing.spec.js │ └── array-testing.js │ ├── string-modification.js │ └── multi-dimensional-arrays.js ├── loops ├── studio │ ├── index.js │ ├── package.json │ ├── solution.js │ └── spec │ │ └── solution.spec.js ├── chapter-examples │ ├── while-Loop-Example.js │ ├── for-Loop-Practice-With-Arrays.js │ ├── for-Loop-Practice-With-Strings.js │ ├── Reversing-a-String.js │ └── Loop-Variable.js └── exercises │ ├── while-Loop-Exercises.js │ └── for-Loop-Exercises.js ├── scope └── chapter-examples │ ├── block-local-scope.js │ └── variable-shadowing.js ├── how-to-write-code ├── consolelogexamples02.js ├── consolelogexamples01.js └── Comments.js ├── more-on-functions ├── chapter-examples │ ├── receieve-function-arguments │ │ ├── function-type-error.js │ │ ├── package.json │ │ └── getValidInput.js │ ├── passing-functions-as-arguments │ │ ├── delayed-message.js │ │ ├── halve-each-number.js │ │ ├── map-array-of-strings.js │ │ └── package.json │ ├── make-function-call-itself │ │ ├── decreasingSum.js │ │ └── function-calls-itself.js │ ├── anonymous-functions │ │ ├── refactor-to-anonymous.js │ │ ├── userInput-is-negative.js │ │ └── package.json │ ├── recursion-base-case │ │ ├── removeI.js │ │ └── factorial.js │ └── package.json ├── studio │ ├── part-three-number-sorting-easy-way.js │ ├── part-one-find-minimum-value.js │ └── part-two-create-sorted-array.js └── exercises │ ├── practice-your-skills.js │ └── raid-a-shuttle.js ├── stringing-characters-together ├── code-snippets │ ├── bracket-notation.js │ ├── mad-libs.js │ └── method-chaining.js └── exercises │ ├── part-one.js │ ├── part-three.js │ └── part-two.js ├── classes ├── exercises │ └── ClassExercises.js ├── chapter-examples │ ├── Inheritance.js │ ├── ClassExamples01.js │ ├── ClassExamples02.js │ └── ClassMethods.js └── studio │ └── ClassStudio.js ├── objects-and-math ├── chapter-examples │ ├── ForInLoop.js │ └── KindnessSelection.js ├── exercises │ └── ObjectExercises.js └── studio │ ├── ObjectsStudio03.js │ ├── ObjectsStudio02.js │ └── ObjectsStudio01.js ├── booleans-and-conditionals ├── exercises │ ├── part-1.js │ ├── part-2.js │ └── part-3.js └── studio │ └── data-variables-conditionals.js └── html └── exercises └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /unit-testing/exercises/tests/RPS.test.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /unit-testing/exercises/tests/checkFive.test.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fetch/studio/script.js: -------------------------------------------------------------------------------- 1 | //TODO: Add Your Code Below 2 | -------------------------------------------------------------------------------- /terminal-commands/launchcode_courses/data_analysis/cities.sql: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /terminal-commands/launchcode_courses/data_analysis/lakes.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /terminal-commands/launchcode_courses/lc_101/unit_1/styles.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /css/exercises/styles.css: -------------------------------------------------------------------------------- 1 | /* Start adding your styling below! */ 2 | -------------------------------------------------------------------------------- /terminal-commands/launchcode_courses/lc_101/unit_1/about_me.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /terminal-commands/launchcode_courses/lc_101/unit_1/hello_world.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /user-input-with-forms/exercises/script.js: -------------------------------------------------------------------------------- 1 | //Code Your Solution Below 2 | -------------------------------------------------------------------------------- /user-input-with-forms/exercises/style.css: -------------------------------------------------------------------------------- 1 | /*/ Code Your Solution Below /*/ 2 | -------------------------------------------------------------------------------- /dom-and-events/exercises/style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | text-decoration: underline; 3 | } 4 | -------------------------------------------------------------------------------- /terminal-commands/launchcode_courses/data_analysis/final_project/.empty_file.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data-and-variables/chapter-examples/bruces-beard.js: -------------------------------------------------------------------------------- 1 | console.log('Bruce's beard'); 2 | -------------------------------------------------------------------------------- /user-input-with-forms/chapter-examples/checkbox-inputs/script.js: -------------------------------------------------------------------------------- 1 | // Add Your Code Below 2 | -------------------------------------------------------------------------------- /user-input-with-forms/chapter-examples/form-validation/script.js: -------------------------------------------------------------------------------- 1 | //Add Your Code Below 2 | -------------------------------------------------------------------------------- /errors-and-debugging/chapter-examples/SyntaxErrors.js: -------------------------------------------------------------------------------- 1 | let day = Wednesday; 2 | console.log(day; -------------------------------------------------------------------------------- /exceptions/chapter-examples/throw-default-error.js: -------------------------------------------------------------------------------- 1 | throw Error('You cannot divide by zero!'); 2 | -------------------------------------------------------------------------------- /functions/try-it/sayHello.js: -------------------------------------------------------------------------------- 1 | function sayHello() { 2 | console.log("Hello, World!"); 3 | } 4 | -------------------------------------------------------------------------------- /user-input-with-forms/chapter-examples/checkbox-inputs/style.css: -------------------------------------------------------------------------------- 1 | /*/ Add Your Code Below /*/ 2 | -------------------------------------------------------------------------------- /user-input-with-forms/chapter-examples/form-validation/style.css: -------------------------------------------------------------------------------- 1 | /*/ Add your Code Below /*/ 2 | -------------------------------------------------------------------------------- /modules/exporting-modules/index.js: -------------------------------------------------------------------------------- 1 | // Import the modules exported from practiceExports.js below: 2 | -------------------------------------------------------------------------------- /arrays/exercises/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "readline-sync": "^1.4.10" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /errors-and-debugging/chapter-examples/Syntax-Highlighting.js: -------------------------------------------------------------------------------- 1 | let name = Julie; 2 | console.log("Hello, name); -------------------------------------------------------------------------------- /loops/studio/index.js: -------------------------------------------------------------------------------- 1 | const shuttleManagement = require('./solution.js'); 2 | 3 | shuttleManagement.runProgram(); -------------------------------------------------------------------------------- /unit-testing/studio/index.js: -------------------------------------------------------------------------------- 1 | 2 | let launchcode = { 3 | 4 | } 5 | 6 | module.exports = launchcode; 7 | 8 | -------------------------------------------------------------------------------- /dom-and-events/studio/scripts.js: -------------------------------------------------------------------------------- 1 | // Write your JavaScript code here. 2 | // Remember to pay attention to page loading! 3 | -------------------------------------------------------------------------------- /loops/chapter-examples/while-Loop-Example.js: -------------------------------------------------------------------------------- 1 | let i = 0; 2 | 3 | while (i < 51) { 4 | console.log(i); 5 | i++; 6 | } -------------------------------------------------------------------------------- /arrays/studio/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "index.js", 3 | "dependencies": { 4 | "readline-sync": "1.4.9" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /css/exercises/script.js: -------------------------------------------------------------------------------- 1 | // You do not need to do anything with script.js right now! Later, we will learn how to add JavaScript to websites! 2 | -------------------------------------------------------------------------------- /data-and-variables/chapter-examples/type-of.js: -------------------------------------------------------------------------------- 1 | console.log(typeof "Hello, World!"); 2 | console.log(typeof 17); 3 | console.log(typeof 3.14); 4 | -------------------------------------------------------------------------------- /scope/chapter-examples/block-local-scope.js: -------------------------------------------------------------------------------- 1 | function myFunction() { 2 | let i = 10; 3 | return 10 + i; 4 | } 5 | 6 | console.log(i); 7 | -------------------------------------------------------------------------------- /data-and-variables/chapter-examples/readline-sync.js: -------------------------------------------------------------------------------- 1 | const input = require('readline-sync'); 2 | 3 | let info = input.question("Question text... "); 4 | -------------------------------------------------------------------------------- /how-to-write-code/consolelogexamples02.js: -------------------------------------------------------------------------------- 1 | console.log("Some Programming Languages:"); 2 | 3 | console.log("Python\nJavaScript\nJava\nC#\nSwift"); 4 | -------------------------------------------------------------------------------- /more-on-functions/chapter-examples/receieve-function-arguments/function-type-error.js: -------------------------------------------------------------------------------- 1 | function callMe(func) { 2 | func(); 3 | } 4 | 5 | callMe("Al"); 6 | -------------------------------------------------------------------------------- /data-and-variables/chapter-examples/readline-greeting-program.js: -------------------------------------------------------------------------------- 1 | const input = require('readline-sync'); 2 | 3 | let name = input.question("Enter your name: "); 4 | -------------------------------------------------------------------------------- /stringing-characters-together/code-snippets/bracket-notation.js: -------------------------------------------------------------------------------- 1 | let jsCreator = "Brendan Eich"; 2 | 3 | console.log(jsCreator[-1]); 4 | console.log(jsCreator[42]); 5 | -------------------------------------------------------------------------------- /unit-testing/chapter-examples/transmission-processor/tests/processor.test.js: -------------------------------------------------------------------------------- 1 | describe("transmission processor", function() { 2 | 3 | // TODO: put tests here 4 | 5 | }); -------------------------------------------------------------------------------- /dom-and-events/studio/LaunchCode_rocketline_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LaunchCodeEducation/javascript-projects/HEAD/dom-and-events/studio/LaunchCode_rocketline_white.png -------------------------------------------------------------------------------- /loops/chapter-examples/for-Loop-Practice-With-Arrays.js: -------------------------------------------------------------------------------- 1 | // create an array variable containing the names 2 | 3 | // write a for loop that prints each name on a different line 4 | -------------------------------------------------------------------------------- /data-and-variables/chapter-examples/more-on-numbers.js: -------------------------------------------------------------------------------- 1 | console.log(42000); 2 | console.log(42,000); 3 | 4 | console.log(42, 17, 56, 34, 11, 4.35, 32); 5 | console.log(3.4, "hello", 45); 6 | -------------------------------------------------------------------------------- /functions/try-it/isPalindrome.js: -------------------------------------------------------------------------------- 1 | function reverse(str) { 2 | return str.split('').reverse().join(''); 3 | } 4 | 5 | function isPalindrome(str) { 6 | return reverse(str) === str; 7 | } 8 | -------------------------------------------------------------------------------- /loops/chapter-examples/for-Loop-Practice-With-Strings.js: -------------------------------------------------------------------------------- 1 | // Create a string variable containing your name. 2 | 3 | 4 | // Write a for loop that prints each character in your name on a different line. -------------------------------------------------------------------------------- /data-and-variables/chapter-examples/more-on-strings.js: -------------------------------------------------------------------------------- 1 | console.log(typeof "17"); 2 | console.log(typeof "3.2"); 3 | 4 | console.log(typeof 'This is a string'); 5 | console.log(typeof "And so is this"); 6 | -------------------------------------------------------------------------------- /functions/try-it/reverse.js: -------------------------------------------------------------------------------- 1 | function reverse(str) { 2 | let lettersArray = str.split(''); 3 | let reversedLettersArray = lettersArray.reverse(); 4 | return reversedLettersArray.join(''); 5 | } 6 | -------------------------------------------------------------------------------- /loops/chapter-examples/Reversing-a-String.js: -------------------------------------------------------------------------------- 1 | let str = "blue"; 2 | let reversed = ""; 3 | 4 | for (let i = 0; i < str.length; i++) { 5 | reversed = str[i] + reversed; 6 | } 7 | 8 | console.log(reversed); -------------------------------------------------------------------------------- /more-on-functions/chapter-examples/passing-functions-as-arguments/delayed-message.js: -------------------------------------------------------------------------------- 1 | function printMessage() { 2 | console.log("The future is now!"); 3 | } 4 | 5 | setTimeout(printMessage, 5000); 6 | -------------------------------------------------------------------------------- /unit-testing/chapter-examples/hello-jest/hello.js: -------------------------------------------------------------------------------- 1 | function hello(name) { 2 | if (name === undefined) 3 | name = "World"; 4 | 5 | return "Hello, " + name + "!"; 6 | } 7 | 8 | module.exports = hello; -------------------------------------------------------------------------------- /modules/exercises/randomSelect.js: -------------------------------------------------------------------------------- 1 | function randomFromArray(arr){ 2 | //Your code here to select a random element from the array passed to the function. 3 | } 4 | 5 | //TODO: Export the randomFromArray function. 6 | -------------------------------------------------------------------------------- /functions/try-it/printMessage.js: -------------------------------------------------------------------------------- 1 | let message = "Hello, World!"; 2 | 3 | function printMessage() { 4 | console.log(message); 5 | } 6 | 7 | printMessage(); 8 | message = "Goodbye"; 9 | printMessage(); 10 | 11 | -------------------------------------------------------------------------------- /unit-testing/studio/tests/launchcode.test.js: -------------------------------------------------------------------------------- 1 | // launchcode.test.js code: 2 | const launchcode = require('../index.js'); 3 | 4 | describe("Testing launchcode", function(){ 5 | 6 | // Write your unit tests here! 7 | 8 | }); -------------------------------------------------------------------------------- /classes/exercises/ClassExercises.js: -------------------------------------------------------------------------------- 1 | // Define your Book class here: 2 | 3 | 4 | // Define your Manual and Novel classes here: 5 | 6 | 7 | // Declare the objects for exercises 2 and 3 here: 8 | 9 | 10 | // Code exercises 4 & 5 here: -------------------------------------------------------------------------------- /errors-and-debugging/chapter-examples/degrees-c-to-k.js: -------------------------------------------------------------------------------- 1 | const input = require('readline-sync'); 2 | 3 | let degreesC = input.question('Temp in degrees C: '); 4 | let degreesK = degreesC + 273.15; 5 | 6 | console.log('Degrees K:', degreesK); 7 | -------------------------------------------------------------------------------- /data-and-variables/chapter-examples/critical-input-detail.js: -------------------------------------------------------------------------------- 1 | const input = require('readline-sync'); 2 | 3 | let num1 = input.question("Enter a number: "); 4 | let num2 = input.question("Enter another number: "); 5 | 6 | console.log(num1 + num2); 7 | -------------------------------------------------------------------------------- /loops/chapter-examples/Loop-Variable.js: -------------------------------------------------------------------------------- 1 | // Experiment with this loop by modifying each of the following: the variable initialization, the boolean condition, and the update expression. 2 | 3 | for (let i = 0; i < 51; i++) { 4 | console.log(i); 5 | } -------------------------------------------------------------------------------- /more-on-functions/chapter-examples/passing-functions-as-arguments/halve-each-number.js: -------------------------------------------------------------------------------- 1 | let nums = [3.14, 42, 4811]; 2 | 3 | // TODO: Write a mapping function 4 | // and pass it to .map() 5 | let halved = nums.map(); 6 | 7 | console.log(halved); 8 | -------------------------------------------------------------------------------- /unit-testing/chapter-examples/palindrome-example/palindrome.js: -------------------------------------------------------------------------------- 1 | function reverse(str) { 2 | return str.split('').reverse().join(''); 3 | } 4 | 5 | function isPalindrome(str) { 6 | return reverse(str) === str; 7 | } 8 | 9 | module.exports = isPalindrome; -------------------------------------------------------------------------------- /how-to-write-code/consolelogexamples01.js: -------------------------------------------------------------------------------- 1 | console.log('Hello, JavaScript.'); 2 | console.log(2001); 3 | console.log("What","do","commas","do?"); 4 | console.log("Does", "adding", "space", "matter?"); 5 | console.log('Launch' + 'Code'); 6 | console.log("LaunchCode was founded in", 2013); 7 | -------------------------------------------------------------------------------- /more-on-functions/chapter-examples/make-function-call-itself/decreasingSum.js: -------------------------------------------------------------------------------- 1 | function decreasingSum(integer) { 2 | if (integer === 1){ 3 | return integer; 4 | } else { 5 | //call decreasingSum function again 6 | } 7 | } 8 | 9 | console.log(decreasingSum(5)); 10 | -------------------------------------------------------------------------------- /more-on-functions/chapter-examples/anonymous-functions/refactor-to-anonymous.js: -------------------------------------------------------------------------------- 1 | function reverse(str) { 2 | let lettersArray = str.split(''); 3 | let reversedLettersArray = lettersArray.reverse(); 4 | return reversedLettersArray.join(''); 5 | } 6 | 7 | console.log(reverse("LaunchCode")); 8 | -------------------------------------------------------------------------------- /arrays/studio/array-string-conversion/index.js: -------------------------------------------------------------------------------- 1 | const studio = require('./array-testing'); 2 | 3 | console.log(studio.reverseCommas()); 4 | console.log(studio.semiDash()); 5 | console.log(studio.reverseSpaces()); 6 | console.log(studio.commaSpace()); 7 | 8 | //NOTE: open the array-testing.js file to begin coding 9 | -------------------------------------------------------------------------------- /data-and-variables/chapter-examples/type-conversion.js: -------------------------------------------------------------------------------- 1 | console.log(Number("2345")); 2 | console.log(typeof Number("2345")); 3 | console.log(Number(17)); 4 | 5 | console.log(Number("23bottles")); 6 | 7 | console.log(String(17)); 8 | console.log(String(123.45)); 9 | console.log(typeof String(123.45)); 10 | -------------------------------------------------------------------------------- /more-on-functions/studio/part-three-number-sorting-easy-way.js: -------------------------------------------------------------------------------- 1 | //Sample arrays for testing: 2 | let nums1 = [5, 10, 2, 42]; 3 | let nums2 = [-2, 0, -10, -44, 5, 3, 0, 3]; 4 | let nums3 = [200, 5, 4, 10, 8, 5, -3.3, 4.4, 0]; 5 | 6 | //Sort each array in ascending order. 7 | 8 | //Sort each array in descending order. 9 | -------------------------------------------------------------------------------- /more-on-functions/chapter-examples/passing-functions-as-arguments/map-array-of-strings.js: -------------------------------------------------------------------------------- 1 | let names = ["Chris", "Jim", "Sally", "Blake", "Paul", "John", "Courtney", "Carly"]; 2 | 3 | // TODO: Write a mapping function 4 | // and pass it to .map() 5 | let firstInitials = names.map(); 6 | 7 | console.log(firstInitials); 8 | -------------------------------------------------------------------------------- /unit-testing/exercises/checkFive.js: -------------------------------------------------------------------------------- 1 | function checkFive(num){ 2 | let result = ''; 3 | if (num < 5){ 4 | result = num + " is less than 5."; 5 | } else if (num === 5){ 6 | result = num + " is equal to 5."; 7 | } else { 8 | result = num + " is greater than 5."; 9 | } 10 | return result; 11 | } -------------------------------------------------------------------------------- /objects-and-math/chapter-examples/ForInLoop.js: -------------------------------------------------------------------------------- 1 | let tortoiseOne = { 2 | species: "Galapagos Tortoise", 3 | name: "Pete", 4 | weight: 919, 5 | age: 85, 6 | diet: ["pumpkins", "lettuce", "cabbage"] 7 | }; 8 | 9 | // Using a for..in loop, iterate through each property in the tortoiseOne object and print the value to the console. -------------------------------------------------------------------------------- /stringing-characters-together/code-snippets/mad-libs.js: -------------------------------------------------------------------------------- 1 | let pluralNoun = ; 2 | let name = ; 3 | let verb = ; 4 | let adjective = ; 5 | let color = ; 6 | 7 | console.log("JavaScript provides a "+ color +" collection of tools — including " + adjective + " syntax and " + pluralNoun + " — that allows "+ name +" to "+ verb +" with strings.") 8 | -------------------------------------------------------------------------------- /exceptions/exercises/divide.js: -------------------------------------------------------------------------------- 1 | // Write a function called 'divide' that takes two parameters: a numerator and a denominator. 2 | 3 | // Your function should return the result of numerator / denominator. 4 | 5 | // However, if the denominator is zero you should throw the error, "Attempted to divide by zero." 6 | 7 | // Code your divide function here: 8 | -------------------------------------------------------------------------------- /user-input-with-forms/exercises/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Rocket Simulation 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /loops/studio/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "loops", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "solution.js", 6 | "scripts": { 7 | "test": "jest" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "readline-sync": "^1.4.10" 13 | }, 14 | "devDependencies": { 15 | "jest": "^29.7.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /dom-and-events/exercises/script.js: -------------------------------------------------------------------------------- 1 | function init () { 2 | const missionAbort = document.getElementById("abortMission"); 3 | const button = document.getElementById("liftoffButton"); 4 | const paragraph = document.getElementById("statusReport"); 5 | 6 | // Put your code for the exercises here. 7 | 8 | } 9 | 10 | window.addEventListener("load", init); 11 | -------------------------------------------------------------------------------- /fetch/studio/style.css: -------------------------------------------------------------------------------- 1 | .avatar { 2 | border-radius: 50%; 3 | height: 100px; 4 | float:right; 5 | } 6 | 7 | .astronaut { 8 | border: 1px solid black; 9 | display: flex; 10 | justify-content: space-between; 11 | width: 500px; 12 | align-items: center; 13 | padding: 5px; 14 | margin-bottom: 20px; 15 | border-radius: 6px; 16 | } 17 | -------------------------------------------------------------------------------- /stringing-characters-together/code-snippets/method-chaining.js: -------------------------------------------------------------------------------- 1 | //String methods can be combined in a process called method chaining. 2 | 3 | let word = 'JavaScript'; 4 | 5 | console.log(word.toUpperCase()); 6 | //Returns ``JAVASCRIPT`` 7 | 8 | //What does ``word.slice(4).toUpperCase()`` return? 9 | 10 | 11 | //Experiment with other combinations (chains) of string methods. 12 | -------------------------------------------------------------------------------- /how-to-write-code/Comments.js: -------------------------------------------------------------------------------- 1 | // This demo shows off comments! 2 | 3 | // console.log("This does not print."); 4 | 5 | console.log("Hello, World!"); // Comments do not have to start at the beginning of a line. 6 | 7 | /* Here is how 8 | to have 9 | multi-line 10 | comments. */ 11 | 12 | console.log("Comments make your code more readable by others."); 13 | -------------------------------------------------------------------------------- /more-on-functions/chapter-examples/recursion-base-case/removeI.js: -------------------------------------------------------------------------------- 1 | function removeI(arr) { 2 | if (/* Enter base case test here */){ 3 | return arr; 4 | } else { 5 | arr.splice(arr.indexOf('i'),1); 6 | return removeI(arr); 7 | } 8 | }; 9 | 10 | let arrayToChange = ['One', 'i', 'c', 'X', 'i', 'i', 54]; 11 | 12 | console.log(removeI(arrayToChange)); 13 | -------------------------------------------------------------------------------- /unit-testing/studio/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "unit-testing", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "jest" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "readline-sync": "^1.4.10" 13 | }, 14 | "devDependencies": { 15 | "jest": "^29.6.4" 16 | } 17 | } -------------------------------------------------------------------------------- /arrays/exercises/part-one-arrays.js: -------------------------------------------------------------------------------- 1 | //Create an array called practiceFile with the following entry: 273.15 2 | 3 | //Use the bracket notation method to add "42" and "hello" to the array. Add these new items one at a time. Print the array after each step to confirm the changes. 4 | 5 | //Use a single .push() to add the following items: false, -4.6, and "87". Print the array to confirm the changes. 6 | -------------------------------------------------------------------------------- /unit-testing/exercises/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "unit-testing", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "checkFive.js", 6 | "scripts": { 7 | "test": "jest" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "readline-sync": "^1.4.10" 13 | }, 14 | "devDependencies": { 15 | "jest": "^29.6.4" 16 | } 17 | } -------------------------------------------------------------------------------- /data-and-variables/exercises/data-and-variables-exercises.js: -------------------------------------------------------------------------------- 1 | // Declare and assign the variables below 2 | 3 | // Use console.log to print the 'typeof' each variable. Print one item per line. 4 | 5 | // Calculate a space mission below 6 | 7 | // Print the results of the space mission calculations below 8 | 9 | // Calculate a trip to the moon below 10 | 11 | // Print the results of the trip to the moon below -------------------------------------------------------------------------------- /exceptions/chapter-examples/try-catch/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "control-flow-type-error", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "readline-sync": "^1.4.10" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /unit-testing/chapter-examples/hello-jest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "unit-testing", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "hello.js", 6 | "scripts": { 7 | "test": "jest" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "readline-sync": "^1.4.10" 13 | }, 14 | "devDependencies": { 15 | "jest": "^29.6.4" 16 | } 17 | } -------------------------------------------------------------------------------- /user-input-with-forms/studio/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 13 | 14 | 15 |
16 | 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /exceptions/chapter-examples/finally/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "control-flow-type-error-finally", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "readline-sync": "^1.4.10" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /modules/exporting-modules/practiceExports.js: -------------------------------------------------------------------------------- 1 | function isPalindrome(str){ 2 | return str === str.split('').reverse().join(''); 3 | } 4 | 5 | function evenOrOdd(num){ 6 | if (num%2===0){ 7 | return "Even"; 8 | } else { 9 | return "Odd"; 10 | } 11 | } 12 | 13 | function randomArrayElement(arr){ 14 | let index = Math.floor(Math.random()*arr.length); 15 | return arr[index]; 16 | } 17 | -------------------------------------------------------------------------------- /unit-testing/chapter-examples/palindrome-example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "unit-testing", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "palindrome.js", 6 | "scripts": { 7 | "test": "jest" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "readline-sync": "^1.4.10" 13 | }, 14 | "devDependencies": { 15 | "jest": "^29.6.4" 16 | } 17 | } -------------------------------------------------------------------------------- /unit-testing/chapter-examples/transmission-processor/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "unit-testing", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "processor.js", 6 | "scripts": { 7 | "test": "jest" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "readline-sync": "^1.4.10" 13 | }, 14 | "devDependencies": { 15 | "jest": "^29.6.4" 16 | } 17 | } -------------------------------------------------------------------------------- /classes/chapter-examples/Inheritance.js: -------------------------------------------------------------------------------- 1 | class Felidae { 2 | constructor() { 3 | this.claws = "retractable"; 4 | } 5 | } 6 | 7 | class Panthera extends Felidae { 8 | constructor() { 9 | super(); 10 | this.roar = "loud"; 11 | } 12 | } 13 | 14 | class Tiger extends Panthera { 15 | constructor() { 16 | super(); 17 | this.hasStripes = "true"; 18 | } 19 | } 20 | 21 | let tigger = new Tiger(); 22 | 23 | console.log(tigger); -------------------------------------------------------------------------------- /more-on-functions/chapter-examples/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Chapter 11: More on Functions Chapter Examples Directory", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "readline-sync": "^1.4.10" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /errors-and-debugging/exercises/Debugging1stSyntaxError.js: -------------------------------------------------------------------------------- 1 | //Run this code first and examine the error message. 2 | //Fix the syntax error then run the code again to check your work. 3 | 4 | let launchReady = false; 5 | let fuelLevel = 17000; 6 | 7 | if (fuelLevel >= 20000 { 8 | console.log('Fuel level cleared.'); 9 | launchReady = true; 10 | } else { 11 | console.log('WARNING: Insufficient fuel!'); 12 | launchReady = false; 13 | } -------------------------------------------------------------------------------- /more-on-functions/chapter-examples/anonymous-functions/userInput-is-negative.js: -------------------------------------------------------------------------------- 1 | const input = require('readline-sync'); 2 | let userInput = input.question("Please enter a number:"); 3 | let logger = function(errorMsg) { 4 | console.log("ERROR: " + errorMsg); 5 | }; 6 | if (userInput < 0) { 7 | // ______("Invalid input"); 8 | } 9 | 10 | // Fill in the blank in line 7 (then uncomment it) so that it logs an error message if userInput is negative. 11 | -------------------------------------------------------------------------------- /more-on-functions/chapter-examples/anonymous-functions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Chapter 11: More on Functions Chapter Examples Directory", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "readline-sync": "^1.4.10" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /scope/chapter-examples/variable-shadowing.js: -------------------------------------------------------------------------------- 1 | const input = require('readline-sync'); 2 | 3 | function hello(name) { 4 | console.log('Hello,', name); 5 | name = 'Ruth'; 6 | return doubleName(name); 7 | } 8 | 9 | function doubleName(name){ 10 | console.log(name+name); 11 | return name+name; 12 | } 13 | 14 | let name = input.question("Please enter your name: "); 15 | 16 | hello(name); 17 | doubleName(name); 18 | console.log(name); 19 | -------------------------------------------------------------------------------- /more-on-functions/chapter-examples/receieve-function-arguments/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Chapter 11: More on Functions Chapter Examples Directory", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "readline-sync": "^1.4.10" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /more-on-functions/chapter-examples/passing-functions-as-arguments/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Chapter 11: More on Functions Chapter Examples Directory", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "readline-sync": "^1.4.10" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /stringing-characters-together/exercises/part-one.js: -------------------------------------------------------------------------------- 1 | let num = 1001; 2 | 3 | //Returns 'undefined'. 4 | console.log(num.length); 5 | 6 | //Use type conversion to print the length (number of digits) of an integer. 7 | 8 | //Follow up: Print the number of digits in a DECIMAL value (e.g. num = 123.45 has 5 digits but a length of 6). 9 | 10 | //Experiment! What if num could be EITHER an integer or a decimal? Add an if/else statement so your code can handle both cases. 11 | -------------------------------------------------------------------------------- /modules/exercises/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Dependencies for Chapter 13 Exercises: Modules", 3 | "version": "1.0.0", 4 | "description": "This package.json file includes all dependencies needed to run code within files contained in this directory", 5 | "main": "index.js", 6 | "dependencies": { 7 | "readline-sync": "^1.4.10" 8 | }, 9 | "scripts": { 10 | "start": "node index.js" 11 | }, 12 | "author": "John Woolbright", 13 | "license": "ISC" 14 | } 15 | -------------------------------------------------------------------------------- /unit-testing/chapter-examples/hello-jest/tests/hello.test.js: -------------------------------------------------------------------------------- 1 | const hello = require('../hello.js'); 2 | 3 | describe("hello world test", function(){ 4 | 5 | test("should return a custom message when name is specified", function(){ 6 | expect(hello("Jest")).toBe("Hello, Jest!"); 7 | }); 8 | 9 | it("should return a general greeting when name is not specified", function(){ 10 | expect(hello()).toBe("Hello, World!"); 11 | }); 12 | 13 | }); -------------------------------------------------------------------------------- /booleans-and-conditionals/exercises/part-1.js: -------------------------------------------------------------------------------- 1 | // Declare and initialize the variables for exercise 1 here: 2 | 3 | // BEFORE running the code, predict what will be printed to the console by the following statements: 4 | 5 | if (engineIndicatorLight === "green") { 6 | console.log("engines have started"); 7 | } else if (engineIndicatorLight === "green blinking") { 8 | console.log("engines are preparing to start"); 9 | } else { 10 | console.log("engines are off"); 11 | } 12 | -------------------------------------------------------------------------------- /html/exercises/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | HTML Exercise 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /data-and-variables/chapter-examples/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Dependencies for Chapter 4: Data and Variables", 3 | "version": "1.0.0", 4 | "description": "This package.json file includes all dependencies needed to run code within files contained in this directory", 5 | "main": "index.js", 6 | "dependencies": { 7 | "readline-sync": "^1.4.10" 8 | }, 9 | "scripts": { 10 | "start": "node index.js" 11 | }, 12 | "author": "John Woolbright", 13 | "license": "ISC" 14 | } 15 | 16 | -------------------------------------------------------------------------------- /errors-and-debugging/exercises/DebuggingRuntimeErrors1.js: -------------------------------------------------------------------------------- 1 | //Run this code first and examine the error message. 2 | //Pay close attention to any line numbers mentioned in the message - these will help locate and repair the mistake in the code. 3 | 4 | let launchReady = false; 5 | let fuelLevel = 17000; 6 | 7 | if (fuellevel >= 20000) { 8 | console.log('Fuel level cleared.'); 9 | launchReady = true; 10 | } else { 11 | console.log('WARNING: Insufficient fuel!'); 12 | launchReady = false; 13 | } -------------------------------------------------------------------------------- /fetch/studio/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Astronauts 7 | 8 | 9 | 10 | 11 |

Astronauts

12 |
13 | 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /unit-testing/exercises/RPS.js: -------------------------------------------------------------------------------- 1 | function whoWon(player1,player2){ 2 | 3 | if (player1 === player2){ 4 | return 'TIE!'; 5 | } 6 | 7 | if (player1 === 'rock' && player2 === 'paper'){ 8 | return 'Player 2 wins!'; 9 | } 10 | 11 | if (player1 === 'paper' && player2 === 'scissors'){ 12 | return 'Player 2 wins!'; 13 | } 14 | 15 | if (player1 === 'scissors' && player2 === 'rock '){ 16 | return 'Player 2 wins!'; 17 | } 18 | 19 | return 'Player 1 wins!'; 20 | } -------------------------------------------------------------------------------- /more-on-functions/chapter-examples/recursion-base-case/factorial.js: -------------------------------------------------------------------------------- 1 | //The following concept check assumes that only positive integers are passed to the function. 2 | 3 | function factorial(integer){ 4 | if (/*enter base case test here*/){ 5 | return integer; 6 | } else { 7 | return integer*(factorial(integer-1)); 8 | } 9 | } 10 | 11 | console.log(factorial(4)); 12 | 13 | //Skill boost! Add validation to return an error message if the function is passed a string, negative number or a decimal value. 14 | -------------------------------------------------------------------------------- /classes/chapter-examples/ClassExamples01.js: -------------------------------------------------------------------------------- 1 | //Try adding new properties inside constructor. 2 | class Astronaut { 3 | constructor(name, age, mass){ 4 | this.name = name; 5 | this.age = age; 6 | this.mass = mass; 7 | } 8 | } 9 | 10 | let fox = new Astronaut('Fox', 7, 12); 11 | 12 | console.log(fox); 13 | console.log(fox.age, fox.color); 14 | 15 | fox.age = 9; 16 | fox.color = 'red'; 17 | 18 | console.log(fox); 19 | console.log(fox.age, fox.color); 20 | 21 | //Try modifying or adding properties below. -------------------------------------------------------------------------------- /exceptions/chapter-examples/try-catch/try-catch.js: -------------------------------------------------------------------------------- 1 | const input = require('readline-sync'); 2 | 3 | let animals = [{name: 'cat'}, {name: 'dog'}]; 4 | let index = Number(input.question("Enter index of animal:")); 5 | 6 | try { 7 | console.log('animal at index:', animals[index].name); 8 | } catch(TypeError) { 9 | console.log("We caught a TypeError, but our program continues to run!"); 10 | console.log("You tried to access an animal at index:", index); 11 | } 12 | 13 | console.log("the code goes on..."); 14 | -------------------------------------------------------------------------------- /classes/studio/ClassStudio.js: -------------------------------------------------------------------------------- 1 | //Declare a class called CrewCandidate with a constructor that takes three parameters—name, mass, and scores. Note that scores will be an array of test results. 2 | 3 | 4 | 5 | //Add methods for adding scores, averaging scores and determining candidate status as described in the studio activity. 6 | 7 | 8 | 9 | //Part 4 - Use the methods to boost Glad Gator’s status to Reserve or higher. How many tests will it take to reach Reserve status? How many to reach Accepted? Remember, scores cannot exceed 100%. -------------------------------------------------------------------------------- /dom-and-events/exercises/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Flight Simulator 5 | 6 | 7 | 8 | 9 |

Flight Simulator

10 |

The shuttle is on the ground

11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /exceptions/chapter-examples/finally/finally.js: -------------------------------------------------------------------------------- 1 | const input = require('readline-sync'); 2 | 3 | let animals = [{name: 'cat'}, {name: 'dog'}]; 4 | let index = Number(input.question("Enter index of animal:")); 5 | 6 | try { 7 | console.log('animal at index:', animals[index].name); 8 | } catch(TypeError) { 9 | console.log("We caught a TypeError, but our program continues to run!"); 10 | } finally { 11 | console.log("You tried to access an animal at index:", index); 12 | } 13 | 14 | console.log("the code goes on..."); 15 | -------------------------------------------------------------------------------- /modules/exercises/ScoreCalcs/averages.js: -------------------------------------------------------------------------------- 1 | function averageForStudent(nameIndex,scores){ 2 | let sum = 0; 3 | for (let i=0; i= 20000) { 5 | console.log('Fuel level cleared.'); 6 | launchReady = true; 7 | } else { 8 | console.log('WARNING: Insufficient fuel!'); 9 | launchReady = false; 10 | } 11 | 12 | if (launchReady) { 13 | console.log("10, 9, 8..."); 14 | console.log("Fed parrot..."); 15 | console.log("6, 5, 4..."); 16 | console.log("Ignition..."); 17 | consoul.log("3, 2, 1..."); 18 | console.log("Liftoff!"); 19 | } else { 20 | console.log("Launch scrubbed."); 21 | } 22 | -------------------------------------------------------------------------------- /arrays/exercises/part-five-arrays.js: -------------------------------------------------------------------------------- 1 | let str = 'In space, no one can hear you code.'; 2 | let arr = ['B', 'n', 'n', 5]; 3 | 4 | //1) Use the split method on the string to identify the purpose of the parameter inside the (). 5 | 6 | //2) Use the join method on the array to identify the purpose of the parameter inside the (). 7 | 8 | //3) Do split or join change the original string/array? 9 | 10 | //4) We can take a comma-separated string and convert it into a modifiable array. Try it! Alphabetize the cargoHold string, and then combine the contents into a new string. 11 | let cargoHold = "water,space suits,food,plasma sword,batteries"; 12 | -------------------------------------------------------------------------------- /more-on-functions/studio/part-one-find-minimum-value.js: -------------------------------------------------------------------------------- 1 | //1) Create a function with an array of numbers as its parameter. The function should iterate through the array and return the minimum value from the array. Hint: Use what you know about if statements to identify and store the smallest value within the array. 2 | 3 | //Sample arrays for testing: 4 | let nums1 = [5, 10, 2, 42]; 5 | let nums2 = [-2, 0, -10, -44, 5, 3, 0, 3]; 6 | let nums3 = [200, 5, 4, 10, 8, 5, -3.3, 4.4, 0]; 7 | 8 | //Using one of the test arrays as the argument, call your function inside the console.log statement below. 9 | 10 | console.log(/* your code here */); 11 | -------------------------------------------------------------------------------- /booleans-and-conditionals/studio/data-variables-conditionals.js: -------------------------------------------------------------------------------- 1 | // Initialize Variables below 2 | 3 | // add logic below to verify total number of astronauts for shuttle launch does not exceed 7 4 | 5 | // add logic below to verify all astronauts are ready 6 | 7 | // add logic below to verify the total mass does not exceed the maximum limit of 850000 8 | 9 | // add logic below to verify the fuel temperature is within the appropriate range of -150 and -300 10 | 11 | // add logic below to verify the fuel level is at 100% 12 | 13 | // add logic below to verify the weather status is clear 14 | 15 | // Verify shuttle launch can proceed based on above conditions 16 | -------------------------------------------------------------------------------- /stringing-characters-together/exercises/part-three.js: -------------------------------------------------------------------------------- 1 | //Part Three section one 2 | 3 | let language = 'JavaScript'; 4 | 5 | //1. Use string concatenation and two slice() methods to print 'JS' from 'JavaScript' 6 | 7 | //2. Without using slice(), use method chaining to accomplish the same thing. 8 | 9 | //3. Use bracket notation and a template literal to print, "The abbreviation for 'JavaScript' is 'JS'." 10 | 11 | //4. Just for fun, try chaining 3 or more methods together, and then print the result. 12 | 13 | //Part Three section Two 14 | 15 | //1. Use the string methods you know to print 'Title Case' from the string 'title case'. 16 | 17 | let notTitleCase = 'title case'; 18 | -------------------------------------------------------------------------------- /arrays/exercises/part-four-arrays.js: -------------------------------------------------------------------------------- 1 | let holdCabinet1 = ['duct tape', 'gum', 3.14, false, 6.022e23]; 2 | let holdCabinet2 = ['orange drink', 'nerf toys', 'camera', 42, 'parsnip']; 3 | 4 | //Explore the methods concat, slice, reverse, and sort to determine which ones alter the original array. 5 | 6 | //1) Print the result of using concat on the two arrays. Does concat alter the original arrays? Verify this by printing holdCabinet1 after using the method. 7 | 8 | //2) Print a slice of two elements from each array. Does slice alter the original arrays? 9 | 10 | //3) reverse the first array, and sort the second. What is the difference between these two methods? Do the methods alter the original arrays? 11 | -------------------------------------------------------------------------------- /fetch/chapter-examples/fetching-data/fetch-weather-part-1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Launch Status 6 | 13 | 14 | 15 |

Launch Status

16 | Weather Conditions 17 |
18 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /user-input-with-forms/chapter-examples/form-submission.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Form Example 6 | 15 | 16 | 17 | 18 |
19 | 20 | 22 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /arrays/studio/string-modification.js: -------------------------------------------------------------------------------- 1 | const input = require('readline-sync'); 2 | let str = "LaunchCode"; 3 | 4 | //1) Use string methods to remove the first three characters from the string and add them to the end. 5 | //Hint - define another variable to hold the new string or reassign the new string to str. 6 | 7 | //Use a template literal to print the original and modified string in a descriptive phrase. 8 | 9 | //2) Modify your code to accept user input. Query the user to enter the number of letters that will be relocated. 10 | 11 | //3) Add validation to your code to deal with user inputs that are longer than the word. In such cases, default to moving 3 characters. Also, the template literal should note the error. 12 | -------------------------------------------------------------------------------- /objects-and-math/chapter-examples/KindnessSelection.js: -------------------------------------------------------------------------------- 1 | function randomSelection(arr){ 2 | let index = Math.floor(Math.random()*arr.length); 3 | return arr[index]; 4 | } 5 | 6 | let happiness = ['Hope', 'Joy', 'Peace', 'Love', 'Kindness', 'Puppies', 'Kittens', 'Tortoise']; 7 | 8 | let words = ['Hello', 'World', 'Python', 'JavaScript', 'Rutabaga']; 9 | 10 | for (i=0; i < 8; i++){ 11 | console.log(randomSelection(happiness)); 12 | } 13 | 14 | //Experiment with the code above. Try to: 15 | //a) Print 3 random selections from each array. 16 | //b) Have the code randomly pick one array, and then print 2 random items from it. 17 | //c) Create a new array, then fill it with one random item from words and happiness. Print the new array. -------------------------------------------------------------------------------- /arrays/exercises/part-two-arrays.js: -------------------------------------------------------------------------------- 1 | let cargoHold = ['oxygen tanks', 'space suits', 'parrot', 'instruction manual', 'meal packs', 'slinky', 'security blanket']; 2 | 3 | //1) Use bracket notation to replace ‘slinky’ with ‘space tether’. Print the array to confirm the change. 4 | 5 | //2) Remove the last item from the array with pop. Print the element removed and the updated array. 6 | 7 | //3) Remove the first item from the array with shift. Print the element removed and the updated array. 8 | 9 | //4) Unlike pop and shift, push and unshift require arguments inside the (). Add the items 1138 and ‘20 meters’ to the the array - the number at the start and the string at the end. Print the updated array to confirm the changes. 10 | 11 | //5) Use a template literal to print the final array and its length. 12 | -------------------------------------------------------------------------------- /user-input-with-forms/chapter-examples/form-post.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Form POST 6 | 15 | 16 | 17 | 18 |
19 | 20 | 22 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /fetch/chapter-examples/fetching-data/fetch-weather-part-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Launch Status 6 | 16 | 17 | 18 |

Launch Status

19 | Weather Conditions 20 |
21 | 22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /user-input-with-forms/chapter-examples/form-validation/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Form Validation 6 | 10 | 11 | 19 | 20 |
21 | 22 | 23 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /errors-and-debugging/exercises/DebuggingSyntaxErrors2.js: -------------------------------------------------------------------------------- 1 | //This block of code hides two syntax errors. 2 | 3 | // Run the code and find the mistakes. 4 | // Only ONE error will be flagged at a time. 5 | // Fix that ONE problem, and then re-run the code to check yer work. Avoid trying to fix multiple issues at once. 6 | 7 | let launchReady = false; 8 | let crewStatus = true; 9 | let computerStatus = 'green'; 10 | 11 | if (crewStatus &&& computerStatus === 'green'){ 12 | console.log('Crew & computer cleared.'); 13 | launchReady = true; 14 | } else { 15 | console.log('WARNING: Crew or computer not ready!'); 16 | launchReady = false; 17 | } 18 | 19 | if (launchReady) { 20 | console.log(("10, 9, 8, 7, 6, 5, 4, 3, 2, 1..."); 21 | console.log("Fed parrot..."); 22 | console.log("Ignition..."); 23 | console.log("Liftoff!"); 24 | } else { 25 | console.log("Launch scrubbed."); 26 | } -------------------------------------------------------------------------------- /css/exercises/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CSS Exercises 7 | 8 | 9 | 10 | 11 | 12 |

My Very Cool Web Page

13 |

Why this Website is Very Cool

14 |
    15 |
  1. I made it!
  2. 16 |
  3. This website is colorful!
  4. 17 |
18 |

Why I love Web Development

19 |

Web Development is a very cool skill that I love learning!

20 |

I love making websites because all I have to do is reload the page to see the changes I have made!

21 | 22 | 23 | -------------------------------------------------------------------------------- /arrays/exercises/part-six-arrays.js: -------------------------------------------------------------------------------- 1 | //Arrays can hold different data types, even other arrays! A multi-dimensional array is one with entries that are themselves arrays. 2 | 3 | //1) Define and initialize the arrays specified in the exercise to hold the name, chemical symbol and mass for different elements. 4 | 5 | //2) Define the array 'table', and use 'push' to add each of the element arrays to it. Print 'table' to see its structure. 6 | 7 | //3) Use bracket notation to examine the difference between printing 'table' with one index vs. two indices (table[][]). 8 | 9 | //4) Using bracket notation and the table array, print the mass of element1, the name for element 2 and the symbol for element26. 10 | 11 | //5) 'table' is an example of a 2-dimensional array. The first “level” contains the element arrays, and the second level holds the name/symbol/mass values. Experiment! Create a 3-dimensional array and print out one entry from each level in the array. 12 | -------------------------------------------------------------------------------- /classes/chapter-examples/ClassMethods.js: -------------------------------------------------------------------------------- 1 | // Here we assign the method inside the constructor 2 | class AstronautI { 3 | constructor(name, age, mass){ 4 | this.name = name; 5 | this.age = age; 6 | this.mass = mass; 7 | this.reportStats = function() { 8 | let stats = `${this.name} is ${this.age} years old and has a mass of ${this.mass} kg.`; 9 | return stats; 10 | } 11 | } 12 | } 13 | 14 | // Here we assign the method outside of the constructor 15 | class AstronautO { 16 | constructor(name, age, mass){ 17 | this.name = name; 18 | this.age = age; 19 | this.mass = mass; 20 | } 21 | 22 | reportStats() { 23 | let stats = `${this.name} is ${this.age} years old and has a mass of ${this.mass} kg.`; 24 | return stats; 25 | } 26 | } 27 | 28 | let fox = new AstronautI('Fox', 7, 12); 29 | let hippo = new AstronautO('Hippo', 25, 1000); 30 | 31 | console.log(fox); 32 | console.log(hippo); -------------------------------------------------------------------------------- /booleans-and-conditionals/exercises/part-2.js: -------------------------------------------------------------------------------- 1 | let engineIndicatorLight = "red blinking"; 2 | let spaceSuitsOn = true; 3 | let shuttleCabinReady = true; 4 | let crewStatus = spaceSuitsOn && shuttleCabinReady; 5 | let computerStatusCode = 200; 6 | let shuttleSpeed = 15000; 7 | 8 | // 3) Write conditional expressions to satisfy the following safety rules: 9 | 10 | // a) If crewStatus is true, print "Crew Ready" else print "Crew Not Ready". 11 | 12 | 13 | // b) If computerStatusCode is 200, print "Please stand by. Computer is rebooting." Else if computerStatusCode is 400, print "Success! Computer online." Else print "ALERT: Computer offline!" 14 | 15 | 16 | // c) If shuttleSpeed is > 17,500, print "ALERT: Escape velocity reached!" Else if shuttleSpeed is < 8000, print "ALERT: Cannot maintain orbit!" Else print "Stable speed". 17 | 18 | 19 | // 4) PREDICT: Do the code blocks shown in the 'predict.txt' file produce the same result? 20 | 21 | console.log(/* "Yes" or "No" */); 22 | -------------------------------------------------------------------------------- /arrays/studio/multi-dimensional-arrays.js: -------------------------------------------------------------------------------- 1 | let food = "water bottles,meal packs,snacks,chocolate"; 2 | let equipment = "space suits,jet packs,tool belts,thermal detonators"; 3 | let pets = "parrots,cats,moose,alien eggs"; 4 | let sleepAids = "blankets,pillows,eyepatches,alarm clocks"; 5 | 6 | //1) Use split to convert the strings into four cabinet arrays. Alphabetize the contents of each cabinet. 7 | 8 | //2) Initialize a cargoHold array and add the cabinet arrays to it. Print cargoHold to verify its structure. 9 | 10 | //3) Query the user to select a cabinet (0 - 3) in the cargoHold. 11 | 12 | //4) Use bracket notation and a template literal to display the contents of the selected cabinet. If the user entered an invalid number, print an error message. 13 | 14 | //5) Modify the code to query the user for BOTH a cabinet in cargoHold AND a particular item. Use the 'includes' method to check if the cabinet contains the selected item, then print “Cabinet ____ DOES/DOES NOT contain ____.” 15 | -------------------------------------------------------------------------------- /errors-and-debugging/exercises/DebuggingLogicErrors1.js: -------------------------------------------------------------------------------- 1 | // Run this sample code as-is and examine the output. 2 | // Should the shuttle have launched? 3 | // Did it? 4 | // Do not worry about fixing the code yet, we will do that in the next series of exercises. 5 | 6 | let launchReady = false; 7 | let fuelLevel = 17000; 8 | let crewStatus = true; 9 | let computerStatus = 'green'; 10 | 11 | if (fuelLevel >= 20000) { 12 | console.log('Fuel level cleared.'); 13 | launchReady = true; 14 | } else { 15 | console.log('WARNING: Insufficient fuel!'); 16 | launchReady = false; 17 | } 18 | 19 | if (crewStatus && computerStatus === 'green'){ 20 | console.log('Crew & computer cleared.'); 21 | launchReady = true; 22 | } else { 23 | console.log('WARNING: Crew or computer not ready!'); 24 | launchReady = false; 25 | } 26 | 27 | if (launchReady) { 28 | console.log('10, 9, 8, 7, 6, 5, 4, 3, 2, 1...'); 29 | console.log('Liftoff!'); 30 | } else { 31 | console.log('Launch scrubbed.'); 32 | } -------------------------------------------------------------------------------- /loops/exercises/while-Loop-Exercises.js: -------------------------------------------------------------------------------- 1 | //Define three variables for the LaunchCode shuttle - one for the starting fuel level, another for the number of astronauts aboard, and the third for the altitude the shuttle reaches. 2 | 3 | 4 | 5 | 6 | 7 | /*Exercise #4: Construct while loops to do the following: 8 | a. Query the user for the starting fuel level. Validate that the user enters a positive, integer value greater than 5000 but less than 30000. */ 9 | 10 | 11 | 12 | 13 | 14 | //b. Use a second loop to query the user for the number of astronauts (up to a maximum of 7). Validate the entry. 15 | 16 | 17 | 18 | 19 | //c. Use a final loop to monitor the fuel status and the altitude of the shuttle. Each iteration, decrease the fuel level by 100 units for each astronaut aboard. Also, increase the altitude by 50 kilometers. 20 | 21 | 22 | 23 | /*Exercise #5: Output the result with the phrase, “The shuttle gained an altitude of ___ km.” 24 | 25 | If the altitude is 2000 km or higher, add “Orbit achieved!” Otherwise add, “Failed to reach orbit.”*/ 26 | -------------------------------------------------------------------------------- /modules/exercises/display.js: -------------------------------------------------------------------------------- 1 | //TODO: Export ONLY the printAll function. 2 | 3 | function printAll(names, tests, scores){ 4 | let header = 'Name'; 5 | let row = ''; 6 | 7 | for (let i = 0; i= 20000) { 11 | console.log('Fuel level cleared.'); 12 | launchReady = true; 13 | } else { 14 | console.log('WARNING: Insufficient fuel!'); 15 | launchReady = false; 16 | } 17 | 18 | console.log("launchReady = ", launchReady); 19 | 20 | if (crewStatus && computerStatus === 'green'){ 21 | console.log('Crew & computer cleared.'); 22 | launchReady = true; 23 | } else { 24 | console.log('WARNING: Crew or computer not ready!'); 25 | launchReady = false; 26 | } 27 | 28 | console.log("launchReady = ", launchReady); -------------------------------------------------------------------------------- /more-on-functions/studio/part-two-create-sorted-array.js: -------------------------------------------------------------------------------- 1 | function findMinValue(arr){ 2 | let min = arr[0]; 3 | for (i = 0; i < arr.length; i++){ 4 | if (arr[i] < min){ 5 | min = arr[i]; 6 | } 7 | } 8 | return min; 9 | } 10 | 11 | //Create a function with an array of numbers as its parameter. This function will return a new array with the numbers sorted from least to greatest value. 12 | 13 | /*Within the function: 14 | 1) Define a new, empty array to hold the final sorted numbers. 15 | 2) Use the findMinValue function to find the minimum value in the old array. 16 | 3) Add the minimum value to the new array, and remove the minimum value from the old array. 17 | 4) Repeat parts b & c until the old array is empty. 18 | 5) Return the new sorted array. 19 | 6) Be sure to print the results in order to verify your code.*/ 20 | 21 | //Your function here... 22 | 23 | /* BONUS MISSION: Refactor your sorting function to use recursion below: 24 | */ 25 | 26 | //Sample arrays for testing: 27 | let nums1 = [5, 10, 2, 42]; 28 | let nums2 = [-2, 0, -10, -44, 5, 3, 0, 3]; 29 | let nums3 = [200, 5, 4, 10, 8, 5, -3.3, 4.4, 0]; 30 | -------------------------------------------------------------------------------- /errors-and-debugging/exercises/DebuggingLogicErrors2.js: -------------------------------------------------------------------------------- 1 | // Let’s break the code down into smaller chunks. 2 | // Consider the first if/else block below. 3 | // Add console.log(launchReady) after this block, then run the program. 4 | 5 | //Given the fuelLevel value, should launchReady be true or false after the check? Is the program behaving as expected? 6 | 7 | let launchReady = false; 8 | let fuelLevel = 17000; 9 | // let crewStatus = true; 10 | // let computerStatus = 'green'; 11 | 12 | if (fuelLevel >= 20000) { 13 | console.log('Fuel level cleared.'); 14 | launchReady = true; 15 | } else { 16 | console.log('WARNING: Insufficient fuel!'); 17 | launchReady = false; 18 | } 19 | 20 | // if (crewStatus && computerStatus === 'green'){ 21 | // console.log('Crew & computer cleared.'); 22 | // launchReady = true; 23 | // } else { 24 | // console.log('WARNING: Crew or computer not ready!'); 25 | // launchReady = false; 26 | // } 27 | 28 | // if (launchReady) { 29 | // console.log('10, 9, 8, 7, 6, 5, 4, 3, 2, 1...'); 30 | // console.log('Liftoff!'); 31 | // } else { 32 | // console.log('Launch scrubbed.'); 33 | // } -------------------------------------------------------------------------------- /loops/exercises/for-Loop-Exercises.js: -------------------------------------------------------------------------------- 1 | /*Exercise #1: Construct for loops that accomplish the following tasks: 2 | a. Print the numbers 0 - 20, one number per line. 3 | b. Print only the ODD values from 3 - 29, one number per line. 4 | c. Print the EVEN numbers 12 to -14 in descending order, one number per line. 5 | d. Challenge - Print the numbers 50 - 20 in descending order, but only if the numbers are multiples of 3. (Your code should work even if you replace 50 or 20 with other numbers). */ 6 | 7 | 8 | 9 | 10 | /*Exercise #2: 11 | Initialize two variables to hold the string “LaunchCode” and the array [1, 5, ‘LC101’, ‘blue’, 42]. 12 | 13 | 14 | Construct ``for`` loops to accomplish the following tasks: 15 | a. Print each element of the array to a new line. 16 | b. Print each character of the string - in reverse order - to a new line. */ 17 | 18 | 19 | 20 | 21 | 22 | /*Exercise #3:Construct a for loop that sorts the array [2, 3, 13, 18, -5, 38, -10, 11, 0, 104] into two new arrays: 23 | a. One array contains the even numbers, and the other holds the odds. 24 | b. Print the arrays to confirm the results. */ -------------------------------------------------------------------------------- /errors-and-debugging/exercises/DebuggingLogicErrors3.js: -------------------------------------------------------------------------------- 1 | // Let’s break the code down into smaller chunks. 2 | // Now consider the second if/else block. 3 | // Add another console.log(launchReady) after this block and run the program. 4 | 5 | // Given the values for crewStatus and computerStatus, should launchReady be true or false after the check? 6 | // Is the program behaving as expected? 7 | 8 | let launchReady = false; 9 | // let fuelLevel = 17000; 10 | let crewStatus = true; 11 | let computerStatus = 'green'; 12 | 13 | // if (fuelLevel >= 20000) { 14 | // console.log('Fuel level cleared.'); 15 | // launchReady = true; 16 | // } else { 17 | // console.log('WARNING: Insufficient fuel!'); 18 | // launchReady = false; 19 | // } 20 | 21 | if (crewStatus && computerStatus === 'green'){ 22 | console.log('Crew & computer cleared.'); 23 | launchReady = true; 24 | } else { 25 | console.log('WARNING: Crew or computer not ready!'); 26 | launchReady = false; 27 | } 28 | 29 | // if (launchReady) { 30 | // console.log('10, 9, 8, 7, 6, 5, 4, 3, 2, 1...'); 31 | // console.log('Liftoff!'); 32 | // } else { 33 | // console.log('Launch scrubbed.'); 34 | // } -------------------------------------------------------------------------------- /errors-and-debugging/exercises/DebuggingLogicErrors4.js: -------------------------------------------------------------------------------- 1 | // Now consider both if/else blocks together (keeping the added console.log lines). 2 | // Run the code and examine the output. 3 | 4 | // Given the values for fuelLevel, crewStatus and computerStatus, should launchReady be true or false? 5 | // Is the program behaving as expected? 6 | 7 | let launchReady = false; 8 | let fuelLevel = 17000; 9 | let crewStatus = true; 10 | let computerStatus = 'green'; 11 | 12 | if (fuelLevel >= 20000) { 13 | console.log('Fuel level cleared.'); 14 | launchReady = true; 15 | } else { 16 | console.log('WARNING: Insufficient fuel!'); 17 | launchReady = false; 18 | } 19 | 20 | console.log("launchReady = ", launchReady); 21 | 22 | if (crewStatus && computerStatus === 'green'){ 23 | console.log('Crew & computer cleared.'); 24 | launchReady = true; 25 | } else { 26 | console.log('WARNING: Crew or computer not ready!'); 27 | launchReady = false; 28 | } 29 | 30 | console.log("launchReady = ", launchReady); 31 | 32 | // if (launchReady) { 33 | // console.log('10, 9, 8, 7, 6, 5, 4, 3, 2, 1...'); 34 | // console.log('Liftoff!'); 35 | // } else { 36 | // console.log('Launch scrubbed.'); 37 | // } -------------------------------------------------------------------------------- /arrays/studio/array-string-conversion/spec/array-testing.spec.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @jest-environment node 3 | */ 4 | 5 | //NOTE: Do NOT modify any of the code below. 6 | 7 | //These are the tests. To run them and check your own status, type "npm test" into the console. Running tests is optional. 8 | const solution = require('../array-testing'); 9 | 10 | describe("Array Studio Solution", function() { 11 | 12 | it("strings[0] is '12,9,6,3' after method chaining", function() { 13 | let testArray = solution.reverseCommas(strings[0]); 14 | expect(testArray).toBe("12,9,6,3"); 15 | }); 16 | 17 | it("strings[1] is 'A-C-E-M' after method chaining", function() { 18 | let testArray = solution.semiDash(strings[1]); 19 | expect(testArray).toBe("A-C-E-M"); 20 | }); 21 | 22 | it("strings[2] is 'string space deliminated' after method chaining", function() { 23 | let testArray = solution.reverseSpaces(strings[2]); 24 | expect(testArray).toBe("string space delimited"); 25 | }); 26 | 27 | it("string[3] is 'caution,typing,require,might,Comma-spaces' after method chaining", function() { 28 | let testArray = solution.commaSpace(strings[3]); 29 | expect(testArray).toBe("caution,typing,require,might,Comma-spaces"); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /fetch/chapter-examples/fetching-data/fetch-weather-part-3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Launch Status 6 | 24 | 25 | 26 |

Launch Status

27 | Weather Conditions 28 |
29 | 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /user-input-with-forms/chapter-examples/checkbox-inputs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | repl.it 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 |

Activities

17 | 18 | 19 | 20 | 21 | 22 |

Ingredients

23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /stringing-characters-together/exercises/part-two.js: -------------------------------------------------------------------------------- 1 | //Part Two Section One 2 | 3 | let dna = " TCG-TAC-gaC-TAC-CGT-CAG-ACT-TAa-CcA-GTC-cAt-AGA-GCT "; 4 | 5 | // First, print out the dna strand in it's current state. 6 | 7 | //1) Use the .trim() method to remove the leading and trailing whitespace, then print the result. 8 | 9 | console.log(/* Your code here. */); 10 | 11 | //2) Change all of the letters in the dna string to UPPERCASE, then print the result. 12 | 13 | console.log(); 14 | 15 | //3) Note that after applying the methods above, the original, flawed string is still stored in dna. To fix this, we need to reassign the changes to back to dna. 16 | //Apply these fixes to your code so that console.log(dna) prints the DNA strand in UPPERCASE with no whitespace. 17 | 18 | console.log(dna); 19 | 20 | //Part Two Section Two 21 | 22 | let dnaTwo = "TCG-TAC-GAC-TAC-CGT-CAG-ACT-TAA-CCA-GTC-CAT-AGA-GCT"; 23 | 24 | //1) Replace the gene "GCT" with "AGG", and then print the altered strand. 25 | 26 | //2) Look for the gene "CAT" with ``indexOf()``. If found print, "CAT gene found", otherwise print, "CAT gene NOT found". 27 | 28 | //3) Use .slice() to print out the fifth gene (set of 3 characters) from the DNA strand. 29 | 30 | //4) Use a template literal to print, "The DNA strand is ___ characters long." 31 | 32 | //5) Just for fun, apply methods to ``dna`` and use another template literal to print, 'taco cat'. 33 | -------------------------------------------------------------------------------- /objects-and-math/studio/ObjectsStudio03.js: -------------------------------------------------------------------------------- 1 | // Code your crewMass function here: 2 | 3 | 4 | // Code your fuelRequired function here: 5 | 6 | 7 | // The pre-selected crew is in the array at the end of this file. 8 | // Feel free to add, remove, or switch crew members as you see fit. 9 | 10 | let candidateA = { 11 | 'name':'Gordon Shumway', 12 | 'species':'alf', 13 | 'mass':90, 14 | 'o2Used':function(hrs){return 0.035*hrs}, 15 | 'astronautID':414 16 | }; 17 | let candidateB = { 18 | 'name':'Lassie', 19 | 'species':'dog', 20 | 'mass':19.1, 21 | 'o2Used':function(hrs){return 0.030*hrs}, 22 | 'astronautID':503 23 | }; 24 | let candidateC = { 25 | 'name':'Jonsey', 26 | 'species':'cat', 27 | 'mass':3.6, 28 | 'o2Used':function(hrs){return 0.022*hrs}, 29 | 'astronautID':796 30 | }; 31 | let candidateD = { 32 | 'name':'Paddington', 33 | 'species':'bear', 34 | 'mass':31.8, 35 | 'o2Used':function(hrs){return 0.047*hrs}, 36 | 'astronautID':291 37 | }; 38 | let candidateE = { 39 | 'name':'Pete', 40 | 'species':'tortoise', 41 | 'mass':417, 42 | 'o2Used':function(hrs){return 0.010*hrs}, 43 | 'astronautID':599 44 | }; 45 | let candidateF = { 46 | 'name':'Hugs', 47 | 'species':'ball python', 48 | 'mass':2.3, 49 | 'o2Used':function(hrs){return 0.018*hrs}, 50 | 'astronautID':890 51 | }; 52 | 53 | let crew = [candidateB,candidateD,candidateF]; 54 | -------------------------------------------------------------------------------- /arrays/studio/array-string-conversion/array-testing.js: -------------------------------------------------------------------------------- 1 | let protoArray1 = "3,6,9,12"; 2 | let protoArray2 = "A;C;M;E"; 3 | let protoArray3 = "space delimited string"; 4 | let protoArray4 = "Comma-spaces, might, require, typing, caution"; 5 | 6 | strings = [protoArray1, protoArray2, protoArray3, protoArray4]; 7 | 8 | //2) 9 | function reverseCommas() { 10 | //TODO: 1. create and instantiate your variables. 11 | let check; 12 | let output; 13 | //TODO: 2. write the code required for this step 14 | 15 | //NOTE: For the code to run properly, you must return your output. this needs to be the final line of code within the function's { }. 16 | return output; 17 | } 18 | 19 | //3) 20 | function semiDash() { 21 | let check; 22 | let output; 23 | //TODO: write the code required for this step 24 | 25 | 26 | return output; 27 | } 28 | 29 | //4) 30 | function reverseSpaces() { 31 | let check; 32 | let output; 33 | //TODO: write the code required for this step 34 | 35 | return output; 36 | } 37 | 38 | //5) 39 | function commaSpace() { 40 | let check; 41 | let output; 42 | //TODO: write the code required for this step 43 | 44 | return output; 45 | } 46 | 47 | // NOTE: Don't add or modify any code below this line or your program might not run as expected. 48 | module.exports = { 49 | strings : strings, 50 | reverseCommas : reverseCommas, 51 | semiDash: semiDash, 52 | reverseSpaces : reverseSpaces, 53 | commaSpace : commaSpace 54 | }; 55 | -------------------------------------------------------------------------------- /objects-and-math/studio/ObjectsStudio02.js: -------------------------------------------------------------------------------- 1 | // Code your orbitCircumference function here: 2 | 3 | 4 | // Code your missionDuration function here: 5 | 6 | 7 | // Copy/paste your selectRandomEntry function here: 8 | 9 | 10 | // Code your oxygenExpended function here: 11 | 12 | 13 | // Candidate data & crew array. 14 | let candidateA = { 15 | 'name':'Gordon Shumway', 16 | 'species':'alf', 17 | 'mass':90, 18 | 'o2Used':function(hrs){return 0.035*hrs}, 19 | 'astronautID':414 20 | }; 21 | let candidateB = { 22 | 'name':'Lassie', 23 | 'species':'dog', 24 | 'mass':19.1, 25 | 'o2Used':function(hrs){return 0.030*hrs}, 26 | 'astronautID':503 27 | }; 28 | let candidateC = { 29 | 'name':'Jonsey', 30 | 'species':'cat', 31 | 'mass':3.6, 32 | 'o2Used':function(hrs){return 0.022*hrs}, 33 | 'astronautID':796 34 | }; 35 | let candidateD = { 36 | 'name':'Paddington', 37 | 'species':'bear', 38 | 'mass':31.8, 39 | 'o2Used':function(hrs){return 0.047*hrs}, 40 | 'astronautID':291 41 | }; 42 | let candidateE = { 43 | 'name':'Pete', 44 | 'species':'tortoise', 45 | 'mass':417, 46 | 'o2Used':function(hrs){return 0.010*hrs}, 47 | 'astronautID':599 48 | }; 49 | let candidateF = { 50 | 'name':'Hugs', 51 | 'species':'ball python', 52 | 'mass':2.3, 53 | 'o2Used':function(hrs){return 0.018*hrs}, 54 | 'astronautID':890 55 | }; 56 | 57 | let crew = [candidateA,candidateC,candidateE]; 58 | -------------------------------------------------------------------------------- /booleans-and-conditionals/exercises/part-3.js: -------------------------------------------------------------------------------- 1 | let engineIndicatorLight = 'red blinking'; 2 | let fuelLevel = 21000; 3 | let engineTemperature = 1200; 4 | 5 | /* 5) Implement the following checks using if/else if/else statements: 6 | 7 | a) If fuelLevel is above 20000 AND engineTemperature is at or below 2500, print "Full tank. Engines good." 8 | 9 | b) If fuelLevel is above 10000 AND engineTemperature is at or below 2500, print "Fuel level above 50%. Engines good." 10 | 11 | c) If fuelLevel is above 5000 AND engineTemperature is at or below 2500, print "Fuel level above 25%. Engines good." 12 | 13 | d) If fuelLevel is at or below 5000 OR engineTemperature is above 2500, print "Check fuel level. Engines running hot." 14 | 15 | e) If fuelLevel is below 1000 OR engineTemperature is above 3500 OR engineIndicatorLight is red blinking print "ENGINE FAILURE IMMINENT!" 16 | 17 | f) Otherwise, print "Fuel and engine status pending..." */ 18 | 19 | // Code 5a - 5f here: 20 | 21 | // 6) a) Create the variable commandOverride, and set it to be true or false. If commandOverride is false, then the shuttle should only launch if the fuel and engine check are OK. If commandOverride is true, then the shuttle will launch regardless of the fuel and engine status. 22 | 23 | /* 6) b) Code the following if/else check: 24 | If fuelLevel is above 20000 AND engineIndicatorLight is NOT red blinking OR commandOverride is true print "Cleared to launch!" Else print "Launch scrubbed!" */ 25 | -------------------------------------------------------------------------------- /objects-and-math/studio/ObjectsStudio01.js: -------------------------------------------------------------------------------- 1 | // Code your selectRandomEntry function here: 2 | 3 | 4 | // Code your buildCrewArray function here: 5 | 6 | 7 | let idNumbers = [291, 414, 503, 599, 796, 890]; 8 | 9 | // Here are the candidates and the 'animals' array: 10 | let candidateA = { 11 | 'name':'Gordon Shumway', 12 | 'species':'alf', 13 | 'mass':90, 14 | 'o2Used':function(hrs){return 0.035*hrs}, 15 | 'astronautID':414 16 | }; 17 | let candidateB = { 18 | 'name':'Lassie', 19 | 'species':'dog', 20 | 'mass':19.1, 21 | 'o2Used':function(hrs){return 0.030*hrs}, 22 | 'astronautID':503 23 | }; 24 | let candidateC = { 25 | 'name':'Jonsey', 26 | 'species':'cat', 27 | 'mass':3.6, 28 | 'o2Used':function(hrs){return 0.022*hrs}, 29 | 'astronautID':796 30 | }; 31 | let candidateD = { 32 | 'name':'Paddington', 33 | 'species':'bear', 34 | 'mass':31.8, 35 | 'o2Used':function(hrs){return 0.047*hrs}, 36 | 'astronautID':291 37 | }; 38 | let candidateE = { 39 | 'name':'Pete', 40 | 'species':'tortoise', 41 | 'mass':417, 42 | 'o2Used':function(hrs){return 0.010*hrs}, 43 | 'astronautID':599 44 | }; 45 | let candidateF = { 46 | 'name':'Hugs', 47 | 'species':'ball python', 48 | 'mass':2.3, 49 | 'o2Used':function(hrs){return 0.018*hrs}, 50 | 'astronautID':890 51 | }; 52 | 53 | let animals = [candidateA,candidateB,candidateC,candidateD,candidateE,candidateF]; 54 | 55 | // Code your template literal and console.log statements: 56 | -------------------------------------------------------------------------------- /dom-and-events/studio/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Flight Simulator 5 | 6 | 7 | 8 | 9 |
10 |

Flight Simulator

11 |

Current Flight Status

12 |

Space shuttle ready for takeoff

13 |

Shuttle Trajectory

14 |
15 |
16 |
17 |

Fuel Levels

18 |

Tank Full

19 |

Astronaut Chat

20 |

Houston, we are ready when you are!

21 |
22 |
23 | 24 |
25 |
26 | 27 | 28 | 29 | 30 |

Space Shuttle Height

31 |

0

miles 32 |
33 |
34 |
35 | 36 | 37 | 38 |
39 | 40 | -------------------------------------------------------------------------------- /modules/exercises/index.js: -------------------------------------------------------------------------------- 1 | //Import modules: 2 | const input = //Import readline-sync. 3 | const averages = //Import functions from averages.js. 4 | const printAll = //Import function from display.js. 5 | const randomSelect = //Import function from randomSelect.js. 6 | 7 | //Candidate data: 8 | let astronauts = ['Fox','Turtle','Cat','Hippo','Dog']; 9 | 10 | const testTitles = ['Math','Fitness','Coding','Nav','Communication']; 11 | 12 | let scores = [[95, 86, 83, 81, 76],[79, 71, 79, 87, 72],[94, 87, 87, 83, 82],[99, 77, 91, 79, 80],[96, 95, 99, 82, 70]]; 13 | 14 | //User interface: 15 | let prompts = ['display all scores', 'average the scores for each test', 'average the scores for each astronaut','select the next spacewalker']; 16 | 17 | for (let i = 0; i 100000){ 3 | return 'green'; 4 | } else if (level > 50000){ 5 | return 'yellow'; 6 | } else { 7 | return 'red'; 8 | } 9 | } 10 | 11 | function holdStatus(arr){ 12 | if (arr.length < 7) { 13 | return `Spaces available: ${7-arr.length}.`; 14 | } else if (arr.length > 7){ 15 | return `Over capacity by ${arr.length-7} items.`; 16 | } else { 17 | return "Full"; 18 | } 19 | } 20 | 21 | let fuelLevel = 200000; 22 | let cargoHold = ['meal kits', 'space suits', 'first-aid kit', 'satellite', 'gold', 'water', 'AE-35 unit']; 23 | 24 | console.log("Fuel level: " + checkFuel(fuelLevel)); 25 | console.log("Hold status: " + holdStatus(cargoHold)); 26 | 27 | /* Steal some fuel from the shuttle: 28 | */ 29 | 30 | //a). Define an anonymous function and set it equal to a variable with a normal, non-suspicious name. The function takes one parameter. This will be the fuel level on the shuttle. 31 | 32 | //b). You must siphon off fuel without alerting the TAs. Inside your function, you want to reduce the fuel level as much as possible WITHOUT changing the color returned by the checkFuel function. 33 | 34 | //c). Once you figure out how much fuel to pump out, return that value. 35 | 36 | //d). Decide where to best place your function call to gather our new fuel. 37 | 38 | /* Next, liberate some of that glorious cargo. 39 | */ 40 | 41 | //a). Define another anonymous function with an array as a parameter, and set it equal to another innocent variable. 42 | 43 | //b). You need to swipe two items from the cargo hold. Choose well. Stealing water ain’t gonna get us rich. Put the swag into a new array and return it from the function. 44 | 45 | //c). The cargo hold has better security than the fuel tanks. It counts how many things are in storage. You need to replace what you steal with something worthless. The count MUST stay the same, or you’ll get caught and thrown into the LaunchCode brig. 46 | 47 | //d). Don’t get hasty, matey! Remember to test your function. 48 | 49 | /* Finally, you need to print a receipt for the accountant. Don’t laugh! That genius knows MATH and saves us more gold than you can imagine. 50 | */ 51 | 52 | //a). Define a function called irs that can take fuelLevel and cargoHold as arguments. 53 | 54 | //b). Call your anonymous fuel and cargo functions from within irs. 55 | 56 | //c). Use a template literal to return, "Raided _____ kg of fuel from the tanks, and stole ____ and ____ from the cargo hold." -------------------------------------------------------------------------------- /loops/studio/solution.js: -------------------------------------------------------------------------------- 1 | const input = require('readline-sync'); 2 | 3 | // Part A: #1 Populate these arrays 4 | 5 | let protein = []; 6 | let grains = []; 7 | let veggies = []; 8 | let beverages = []; 9 | let desserts = []; 10 | 11 | 12 | function mealAssembly(protein, grains, veggies, beverages, desserts, numMeals) { 13 | let pantry = [protein, grains, veggies, beverages, desserts]; 14 | let meals = []; 15 | 16 | /// Part A #2: Write a ``for`` loop inside this function 17 | /// Code your solution for part A #2 below this comment (and above the return statement) ... /// 18 | 19 | 20 | return meals; 21 | } 22 | 23 | 24 | function askForNumber() { 25 | numMeals = input.question("How many meals would you like to make?"); 26 | 27 | /// CODE YOUR SOLUTION TO PART B here /// 28 | 29 | return numMeals; 30 | } 31 | 32 | 33 | function generatePassword(string1, string2) { 34 | let code = ''; 35 | 36 | /// Code your Bonus Mission Solution here /// 37 | 38 | return code; 39 | } 40 | 41 | function runProgram() { 42 | 43 | /// TEST PART A #2 HERE /// 44 | /// UNCOMMENT the two lines of code below that invoke the mealAssembly function (starting with 'let meals =') and print the result /// 45 | /// Change the final input variable (aka numMeals) here to ensure your solution makes the right number of meals /// 46 | /// We've started with the number 2 for now. Does your solution still work if you change this value? /// 47 | 48 | // let meals = mealAssembly(protein, grains, veggies, beverages, desserts, 2); 49 | // console.log(meals) 50 | 51 | 52 | /// TEST PART B HERE /// 53 | /// UNCOMMENT the next two lines to test your ``askForNumber`` solution /// 54 | /// Tip - don't test this part until you're happy with your solution to part A #2 /// 55 | 56 | // let mealsForX = mealAssembly(protein, grains, veggies, beverages, desserts, askForNumber()); 57 | // console.log(mealsForX); 58 | 59 | /// TEST PART C HERE /// 60 | /// UNCOMMENT the remaining commented lines and change the password1 and password2 strings to ensure your code is doing its job /// 61 | 62 | // let password1 = ''; 63 | // let password2 = ''; 64 | // console.log("Time to run the password generator so we can update the menu tomorrow.") 65 | // console.log(`The new password is: ${generatePassword(password1, password2)}`); 66 | } 67 | 68 | module.exports = { 69 | protein: protein, 70 | grains: grains, 71 | veggies: veggies, 72 | beverages: beverages, 73 | desserts: desserts, 74 | mealAssembly: mealAssembly, 75 | askForNumber: askForNumber, 76 | generatePassword: generatePassword, 77 | runProgram: runProgram 78 | }; 79 | -------------------------------------------------------------------------------- /functions/studio/studio-functions.js: -------------------------------------------------------------------------------- 1 | //We want to COMPLETELY reverse an array by flipping the order of the entries AND flipping the order of characters in each element. 2 | 3 | // Part One: Reverse Characters 4 | 5 | // 1. Define the function as reverseCharacters. Give it one parameter, which will be the string to reverse. 6 | // 2. Within the function, split the string into an array, then reverse the array. 7 | // 3. Use join to create the reversed string and return that string from the function. 8 | // 4. Below the function, define and initialize a variable to hold a string. 9 | // 5. Use console.log(reverseCharacters(myVariableName)); to call the function and verify that it correctly reverses the characters in the string. 10 | // 6. Optional: Use method chaining to reduce the lines of code within the function. 11 | 12 | // Part Two: Reverse Digits 13 | 14 | // 1. Add an if statement to reverseCharacters to check the typeof the parameter. 15 | // 2. If typeof is ‘string’, return the reversed string as before. 16 | // 3. If typeof is ’number’, convert the parameter to a string, reverse the characters, then convert it back into a number. 17 | // 4. Return the reversed number. 18 | // 5. Be sure to print the result returned by the function to verify that your code works for both strings and numbers. Do this before moving on to the next exercise. 19 | 20 | // Part Three: Complete Reversal - Create a new function with one parameter, which is the array we want to change. The function should: 21 | 22 | // 1. Define and initialize an empty array. 23 | // 2. Loop through the old array. 24 | // 3. For each element in the old array, call reverseCharacters to flip the characters or digits. 25 | // 4. Add the reversed string (or number) to the array defined in part ‘a’. 26 | // 5. Return the final, reversed array. 27 | // 6. Be sure to print the results from each test case in order to verify your code. 28 | 29 | let arrayTest1 = ['apple', 'potato', 'Capitalized Words']; 30 | let arrayTest2 = [123, 8897, 42, 1168, 8675309]; 31 | let arrayTest3 = ['hello', 'world', 123, 'orange']; 32 | 33 | // Bonus Missions 34 | 35 | // 1. Have a clear, descriptive name like funPhrase. 36 | // 2. Retrieve only the last character from strings with lengths of 3 or less. 37 | // 3. Retrieve only the first 3 characters from strings with lengths larger than 3. 38 | // 4. Use a template literal to return the phrase We put the '___' in '___'. Fill the first blank with the modified string, and fill the second blank with the original string. 39 | 40 | // Test Function 41 | 42 | // 1. Outside of the function, define the variable str and initialize it with a string (e.g. 'Functions rock!'). 43 | // 2. Call your function and print the returned phrase. 44 | 45 | // Area of rectangle equal to length x width 46 | 47 | // 1. Define a function with the required parameters to calculate the area of a rectangle. 48 | // 2. The function should return the area, NOT print it. 49 | // 3. Call your area function by passing in two arguments - the length and width. 50 | // 4. If only one argument is passed to the function, then the shape is a square. Modify your code to deal with this case. 51 | // 5. Use a template literal to print, “The area is ____ cm^2.” 52 | -------------------------------------------------------------------------------- /loops/studio/spec/solution.spec.js: -------------------------------------------------------------------------------- 1 | const studentsolution = require('../solution.js'); 2 | 3 | describe ("Loops studio solution", function() { 4 | 5 | let protein, grains, veggies, beverages, desserts; 6 | 7 | beforeAll(async function () { 8 | protein = studentsolution.protein; 9 | grains = studentsolution.grains; 10 | veggies = studentsolution.veggies; 11 | beverages = studentsolution.beverages; 12 | desserts = studentsolution.desserts; 13 | }); 14 | 15 | 16 | it("desserts is initialized", function() { 17 | expect(desserts).toContain("apple"); 18 | expect(desserts).toContain("banana"); 19 | expect(desserts).toContain("more kale"); 20 | expect(desserts).toContain("ice cream"); 21 | expect(desserts).toContain("chocolate"); 22 | expect(desserts).toContain("kiwi"); 23 | expect(desserts.length).toBe(6); 24 | }); 25 | 26 | it("beverages is initialized", function() { 27 | expect(beverages).toContain("juice"); 28 | expect(beverages).toContain("milk"); 29 | expect(beverages).toContain("water"); 30 | expect(beverages).toContain("soy milk"); 31 | expect(beverages).toContain("soda"); 32 | expect(beverages).toContain("tea"); 33 | expect(beverages.length).toBe(6); 34 | }); 35 | 36 | it("protein is initialized", function () { 37 | expect(protein).toContain("chicken"); 38 | expect(protein).toContain("pork"); 39 | expect(protein).toContain("tofu"); 40 | expect(protein).toContain("beef"); 41 | expect(protein).toContain("fish"); 42 | expect(protein).toContain("beans"); 43 | expect(protein.length).toBe(6); 44 | }); 45 | 46 | it("grains is initialized", function() { 47 | expect(grains).toContain("rice"); 48 | expect(grains).toContain("pasta"); 49 | expect(grains).toContain("corn"); 50 | expect(grains).toContain("potato"); 51 | expect(grains).toContain("quinoa"); 52 | expect(grains).toContain("crackers"); 53 | expect(grains.length).toBe(6); 54 | }); 55 | 56 | it("veggies is initialized", function() { 57 | expect(veggies).toContain("peas"); 58 | expect(veggies).toContain("green beans"); 59 | expect(veggies).toContain("kale"); 60 | expect(veggies).toContain("edamame"); 61 | expect(veggies).toContain("broccoli"); 62 | expect(veggies).toContain("asparagus"); 63 | expect(veggies.length).toBe(6); 64 | }); 65 | 66 | it("mealAssembly produces proper number and size of meals", function() { 67 | let testMeals1 = studentsolution.mealAssembly(protein, grains, veggies, beverages, desserts, 6); 68 | expect(testMeals1.length).toBe(6); 69 | expect(testMeals1[0].length).toBe(5); 70 | let testMeals2 = studentsolution.mealAssembly(protein, grains, veggies, beverages, desserts, 3); 71 | expect(testMeals2.length).toBe(3); 72 | expect(testMeals2[0].length).toBe(5); 73 | let testMeals3 = studentsolution.mealAssembly(protein, grains, veggies, beverages, desserts, 4); 74 | expect(testMeals3.length).toBe(4); 75 | expect(testMeals3[3].length).toBe(5); 76 | }); 77 | 78 | /// BONUS MISSION TEST /// 79 | 80 | // it("generatePassword returns jumbled words", function() { 81 | // expect(studentsolution.generatePassword("LoOt", "oku!")).toEqual("LookOut!"); 82 | // }) 83 | }); --------------------------------------------------------------------------------