17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/05-02-prototypal-inheritance/solution-code/02-make-car-function/app.js:
--------------------------------------------------------------------------------
1 | // Create a makeCar function
2 | // ---
3 | // Define a function: `makeCar()` that takes two parameters (model, color) and
4 | // makes a new object literal for a car using those params, and returns that object.
5 |
6 | function makeCar(model, color){
7 | return {
8 | model: model,
9 | color: color,
10 | fuel: 100,
11 | drive: function() {
12 | this.fuel--;
13 | return 'Vroom!';
14 | },
15 | refuel: function() {
16 | this.fuel = 100;
17 | }
18 | }
19 | }
20 | var celica = makeCar("Toy-Yoda Celica", "limegreen");
21 | console.log(celica);
22 |
--------------------------------------------------------------------------------
/04-04-dom-and-jquery-continued/solution-code/pixart_js/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | i ♥ js
7 |
8 |
9 |
Pixel Art!
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/03-14-data-types/data-types-exercise.md:
--------------------------------------------------------------------------------
1 | ## Data Types
2 |
3 | What is the return value of each of the below code snippets? Come up with an answer before testing them out in the console.
4 |
5 | ```js
6 | typeof( 15 );
7 | // Include your answer below each line using a comment, like this.
8 |
9 | typeof( 5.5 );
10 | typeof( NaN );
11 | typeof( "hello" );
12 | typeof( true )
13 | typeof( 1 != 2 );
14 |
15 | "hamburger" + "s";
16 | "hamburgers" - "s";
17 | "1" + "3"
18 | "1" - "3"
19 | "johnny" + 5;
20 | "johnny" - 5
21 | 99 * "luftbaloons";
22 | ```
23 |
24 | What's going on in the second half of the previous question? Are there any "rules" we can pull from those examples?
25 |
--------------------------------------------------------------------------------
/03-16-collections-and-loops/solution-code/verify-age.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | var age = 25
4 |
5 | if (age < 16) {
6 | console.log('You can go to school!')
7 | } else if (age >= 16 && age < 18) {
8 | console.log('You can drive!')
9 | } else if (age >= 18 && age < 21) {
10 | console.log('You can vote!')
11 | } else if (age >= 21 && age < 25) {
12 | console.log('You can drink alcohol!')
13 | } else if (age >= 25 && age < 35) {
14 | console.log('You can rent a car!')
15 | } else if (age >= 35 && age < 62) {
16 | console.log('You can run for president!')
17 | } else if (age >= 62) {
18 | console.log('You can collect social security!')
19 | } else {
20 | console.log('Please enter a correct age value')
21 | }
--------------------------------------------------------------------------------
/03-30-dom-and-jquery/starter-code/js_dom_exercise/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
');
24 | var $newItemText = $('#new-thing');
25 | $newLi.html($newItemText.val());
26 | $newItemText.val('');
27 | if ($newLi.html() !== '') {
28 | list.append($newLi);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/03-01-prework/readme.md:
--------------------------------------------------------------------------------
1 | # Before Class
2 |
3 | 1. Complete the [JS Pre-Work Prompt](./prework.pdf). You should all have received this already, but in any case, make sure you have gone through it before the first class. There are some extra tutorials and resources included, so be sure take a look!
4 |
5 | 2. Accept your Slack invitation. Slack is a group chat tool you'll be using to stay in touch with your instructors and classmates during JS. I've just sent you all email invites to our class specific team. Once you're signed into Slack, upload a profile picture and introduce yourself in the #general channel!
6 |
7 | 3. Fill out your [GA Student Profile](https://mobilega.typeform.com/to/DbXlOu?course_name=javascript-development&campus=washington-dc&start_date=3-7-2016&github=yes&location=us&core_id=19434)
8 |
--------------------------------------------------------------------------------
/03-23-project-1/starter_code/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "starter-code",
3 | "version": "0.0.0",
4 | "private": true,
5 | "author": "Jesse Shawl ",
6 | "description": "A simple helpful robot for your Company",
7 | "dependencies": {
8 | "hubot": "^2.18.0",
9 | "hubot-diagnostics": "0.0.1",
10 | "hubot-google-images": "^0.2.6",
11 | "hubot-google-translate": "^0.2.0",
12 | "hubot-help": "^0.1.3",
13 | "hubot-heroku-keepalive": "^1.0.2",
14 | "hubot-maps": "0.0.2",
15 | "hubot-pugme": "^0.1.0",
16 | "hubot-redis-brain": "0.0.3",
17 | "hubot-rules": "^0.1.1",
18 | "hubot-scripts": "^2.16.2",
19 | "hubot-shipit": "^0.2.0",
20 | "hubot-slack": "^3.4.2"
21 | },
22 | "engines": {
23 | "node": "0.10.x"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/04-06-review/starter-code/cash-register/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Cash Register - CodePen
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Thank You!
13 |
14 |
15 |
16 |
17 |
18 |
Total
19 |
$0.00
20 |
21 |
22 |
23 |
24 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/04-11-ajax-and-apis/solution-code/04-open-weather-map/main.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | - Sign up for openweathermap.org and generate an API key.
4 | - User either $.ajax or $.get to pull weather current data .
5 | for Washington DC (hint: http://api.openweathermap.org/data/2.5/weather?q=...).
6 | - Print the temperature in console.
7 | - Bonus 1: add a form prompting user for the city and state.
8 | - Bonus 2: convert answer from kelvin to fahrenheit.
9 |
10 | */
11 |
12 | 'use strict';
13 | (function() {
14 | var weatherUrl = "http://api.openweathermap.org/data/2.5/weather?q=Washington,DC";
15 | var apiKey = "2490c4b3eae6bcf3343a6556a99ab9c2";
16 | var url = weatherUrl + "&appid=" + apiKey
17 | $.getJSON(url, function(response){
18 | console.log(response.main.temp)
19 | })
20 |
21 | })();
22 |
--------------------------------------------------------------------------------
/03-30-dom-and-jquery/starter-code/js_dom_exercise/main.js:
--------------------------------------------------------------------------------
1 | /* DOM Manipulation: Independent Practice
2 |
3 | To complete this excercise, you must meet the following requirements:
4 |
5 | - Change the value of the element with the name id to be whatever the user inputs when page first loads.
6 | - When the user clicks the "#new-thing-button" button, add whatever is in the input box to the "#fav-list" list.
7 | - Clear the input box when the user clicks the button.
8 | - Bonus: only add item if the input box is not blank (hint: check innerHTML property)
9 |
10 | */
11 |
12 |
13 | window.onload = function() {
14 | var your_name = prompt("What is your name?");
15 | var button;
16 | var thing_list;
17 |
18 | };
19 |
20 | var MyApp = {
21 | add_to_list: function(list) {
22 |
23 | }
24 | };
25 |
--------------------------------------------------------------------------------
/04-06-review/starter-code/cash-register/obfuscated/js/main.js:
--------------------------------------------------------------------------------
1 | eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('1 e=0.3("o");e.n("a",a);1 8=0.3(\'8\');m a(h){h.q();1 5=0.3(\'f\');5=6(5.l).i(2);1 7=0.b("p");1 k=0.b("j");1 9=0.b("j");9.d=5;7.c(k);7.c(9);8.c(7);0.3(\'f\').l=\'\';4=6(0.3(\'4\').d.r(/\\$|,/g,\'\'));4=4+6(5);0.3(\'4\').d="$"+6(4).i(2)}',28,28,'document|var||getElementById|total|val|parseFloat|row|entries|valCell|submit|createElement|appendChild|innerHTML|form|newEntry||event|toFixed|td|cell|value|function|addEventListener|entry|tr|preventDefault|replace'.split('|'),0,{}))
2 |
3 |
--------------------------------------------------------------------------------
/04-11-ajax-and-apis/solution-code/02-movie-browser/readme.md:
--------------------------------------------------------------------------------
1 | # Movie Browser
2 |
3 | Use the [Open Movie Database API](http://www.omdbapi.com/) to build a single-page movie browser app.
4 |
5 | ## Requirements
6 |
7 | 1. The `"#movie-select"` should be hidden by default.
8 |
9 | 2. When the user may submits a search for a movie keyword...
10 | - the `"#movie-select"` field should be un-hidden,
11 | - it should be populated with all search results,
12 | - and the first select option should read "Movies matching `keyword`…".
13 |
14 | 3. Whenever the user selects a title from the `#movie-select` field (HINT: listen for a `"change"` event), the app should populate the `"#movie-detail"` div with that movie's title and poster image.
15 |
16 | ## Take a look:
17 |
18 | http://ga-dc.github.io/movie-browser
19 |
--------------------------------------------------------------------------------
/04-11-ajax-and-apis/starter-code/02-movie-browser/readme.md:
--------------------------------------------------------------------------------
1 | # Movie Browser
2 |
3 | Use the [Open Movie Database API](http://www.omdbapi.com/) to build a single-page movie browser app.
4 |
5 | ## Requirements
6 |
7 | 1. The `"#movie-select"` should be hidden by default.
8 |
9 | 2. When the user may submits a search for a movie keyword...
10 | - the `"#movie-select"` field should be un-hidden,
11 | - it should be populated with all search results,
12 | - and the first select option should read "Movies matching `keyword`…".
13 |
14 | 3. Whenever the user selects a title from the `#movie-select` field (HINT: listen for a `"change"` event), the app should populate the `"#movie-detail"` div with that movie's title and poster image.
15 |
16 | ## Take a look:
17 |
18 | http://ga-dc.github.io/movie-browser
19 |
--------------------------------------------------------------------------------
/03-30-dom-and-jquery/solution-code/jquery_exercise/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/05-02-prototypal-inheritance/solution-code/07-oop-monkey-js/readme.md:
--------------------------------------------------------------------------------
1 | # Monkies!!
2 |
3 | Create a `Monkey` constructor in `lib/monkey.js`, which has the following attributes:
4 | * name - (a string)
5 | * species - (a string)
6 | * foodsEaten - (an array)
7 |
8 | And the following methods:
9 | * eat(food) - adds the food (a string) to the list of foods eaten
10 | * introduce() - introduces self, with name, species, and what it's eaten.
11 |
12 | ## Setup
13 |
14 | Install dependencies:
15 | ```bash
16 | $ npm install -g jasmine-node
17 | $ npm install
18 | ```
19 |
20 | ## Goal
21 |
22 | Run tests using `jasmine-node spec`. Write code in your Monkey constructor to make the tests pass.
23 |
24 | Make sure to use the Monkey prototype so that you're not creating multiple copies of the functions for your monkies!
25 |
26 | ## Bonus
27 |
28 | Uncomment the bonus tests in `spec/monkey_spec` and make them pass.
29 |
--------------------------------------------------------------------------------
/05-02-prototypal-inheritance/starter-code/07-oop-monkey-js/readme.md:
--------------------------------------------------------------------------------
1 | # Monkies!!
2 |
3 | Create a `Monkey` constructor in `lib/monkey.js`, which has the following attributes:
4 | * name - (a string)
5 | * species - (a string)
6 | * foodsEaten - (an array)
7 |
8 | And the following methods:
9 | * eat(food) - adds the food (a string) to the list of foods eaten
10 | * introduce() - introduces self, with name, species, and what it's eaten.
11 |
12 | ## Setup
13 |
14 | Install dependencies:
15 | ```bash
16 | $ npm install -g jasmine-node
17 | $ npm install
18 | ```
19 |
20 | ## Goal
21 |
22 | Run tests using `jasmine-node spec`. Write code in your Monkey constructor to make the tests pass.
23 |
24 | Make sure to use the Monkey prototype so that you're not creating multiple copies of the functions for your monkies!
25 |
26 | ## Bonus
27 |
28 | Uncomment the bonus tests in `spec/monkey_spec` and make them pass.
29 |
--------------------------------------------------------------------------------
/04-04-dom-and-jquery-continued/solution-code/templating_codealong/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
Hello World
9 |
10 |
Favorite Things
11 |
12 |
13 |
14 |
18 |
19 |
20 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/03-21-functions-and-scope/starter-code/dice/js/app.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Creating a page where every time the user hits the "Roll Dice" button, the screen randomly updates the two dice. Use the html and css code included in the starter code folder to get started.
4 |
5 | 1) Write down pseudocode for the following program.
6 |
7 | 2) Follow the steps below to write your code.
8 | * generate a random number between 1 - 6 and store to a variable, random1
9 | * generate a random number between 1 - 6 and store to a variable, random2
10 | * combine 'dice-' and random1 to form the random class for the first die, firstDie
11 | * combine 'dice-' and random1 to form the random class for the second die, secondDie
12 | * get the first die by ID and update the class to firstDie (hint: document.getElementById)
13 | * get the first die by ID and update the class to secondDie (hint:document.getElementById)
14 |
15 | 3) Check to see if the Dice Roll has been hit, if it has run the diceRoll function.
16 |
17 | */
18 |
--------------------------------------------------------------------------------
/03-30-dom-and-jquery/solution-code/js_dom_exercise/main.js:
--------------------------------------------------------------------------------
1 | window.onload = function() {
2 | var your_name = prompt("What is your name?"),
3 | button,
4 | thing_list;
5 |
6 | document.getElementById('name').innerHTML = your_name;
7 |
8 | thing_list = document.getElementById('fav-list');
9 |
10 | button = document.getElementById('new-thing-button');
11 | button.onclick = function(event) {
12 | event.preventDefault();
13 | MyApp.add_to_list(thing_list);
14 | return false;
15 | };
16 | };
17 |
18 | // We can define things outside of the window.onload which are evaluated
19 | // only when called.
20 | MyApp = {};
21 |
22 | MyApp.add_to_list = function(list) {
23 | var new_li = document.createElement('li'),
24 | new_item_text = document.getElementById('new-thing');
25 | new_li.innerHTML = new_item_text.value;
26 | new_item_text.value = "";
27 | if (new_li.innerHTML !== "") {
28 | list.appendChild(new_li);
29 | }
30 | return true;
31 | }
32 |
--------------------------------------------------------------------------------
/04-06-review/starter-code/atm/atm.css:
--------------------------------------------------------------------------------
1 | @import url(http://fonts.googleapis.com/css?family=Oleo+Script);
2 | @import url(http://fonts.googleapis.com/css?family=Ruluko);
3 |
4 | body {
5 | font-family: 'Ruluko', sans-serif;
6 | margin: 0px auto;
7 | text-align: center;
8 | width: 700px;
9 | }
10 |
11 | .header {
12 | margin: 50px 0px;
13 | }
14 |
15 | .title {
16 | color: #F52F4F;
17 | font-family: 'Oleo Script', cursive;
18 | font-size: 50px;
19 | }
20 |
21 | .account {
22 | background-color: #6C9A74;
23 | border: 1px solid #295A33;
24 | border-radius: 15px;
25 | display: inline-block;
26 | margin: 10px;
27 | padding: 10px;
28 | width: 300px;
29 | }
30 |
31 | .balance {
32 | background-color: #E3E3E3;
33 | border: 1px solid #676767;
34 | border-radius: 15px;
35 | font-family: 'Ruluko', sans-serif;
36 | font-size: 50px;
37 | margin: 5px;
38 | padding: 25px 0px;
39 | }
40 |
41 | .zero {
42 | background-color: #F52F4F;
43 | color: #FFFFFF;
44 | }
45 |
--------------------------------------------------------------------------------
/03-21-functions-and-scope/solution-code/currency-converter/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Currency Converter
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
Want to see what your neighbors are Instagramming?
18 |
23 |
24 |
25 |
26 |
27 |
Here are the images in your neighborhood:
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/05-02-prototypal-inheritance/solution-code/08-prototypal-inheritance/app.js:
--------------------------------------------------------------------------------
1 | ////////////////////////////////
2 | // Animal (Parent) Class
3 | ////////////////////////////////
4 | function Animal( name ){
5 | this.name = name;
6 | }
7 |
8 | Animal.prototype.kingdom = "Animalia";
9 | Animal.prototype.breathe = function() {console.log("Inhale... exhale...")};
10 |
11 |
12 | ////////////////////////////////
13 | // HELLO THIS IS DOG
14 | ////////////////////////////////
15 | function Dog(name, breed){
16 | this.name = name;
17 | this.breed = breed;
18 | }
19 |
20 | // Important! Set up the link in the prototype chain connecting Dogs to Animals
21 | Dog.prototype = new Animal();
22 |
23 | // Add any methods / properties shared by all dogs.
24 | Dog.prototype.bark = function(){ console.log("Woof")};
25 | Dog.prototype.species = "Canis canis"
26 |
27 | ////////////////////////////////
28 | // Testing our dawgs
29 | ////////////////////////////////
30 | var spot = new Dog("Spot", "Beagle");
31 |
32 | // from Animal prototype
33 | spot.kingdom;
34 | spot.breathe();
35 |
36 | // from Dog prototype
37 | spot.bark();
38 | spot.species;
39 |
40 | // from Dog properties
41 | spot.name;
42 | spot.breed;
43 |
--------------------------------------------------------------------------------
/05-02-prototypal-inheritance/starter-code/08-prototypal-inheritance/app.js:
--------------------------------------------------------------------------------
1 | ////////////////////////////////
2 | // Animal (Parent) Class
3 | ////////////////////////////////
4 | function Animal( name ){
5 | this.name = name;
6 | }
7 |
8 | Animal.prototype.kingdom = "Animalia";
9 | Animal.prototype.breathe = function() {console.log("Inhale... exhale...")};
10 |
11 |
12 | ////////////////////////////////
13 | // HELLO THIS IS DOG
14 | ////////////////////////////////
15 | function Dog(name, breed){
16 | this.name = name;
17 | this.breed = breed;
18 | }
19 |
20 | // Important! Set up the link in the prototype chain connecting Dogs to Animals
21 | Dog.prototype = new Animal();
22 |
23 | // Add any methods / properties shared by all dogs.
24 | Dog.prototype.bark = function(){ console.log("Woof")};
25 | Dog.prototype.species = "Canis canis"
26 |
27 | ////////////////////////////////
28 | // Testing our dawgs
29 | ////////////////////////////////
30 | var spot = new Dog("Spot", "Beagle");
31 |
32 | // from Animal prototype
33 | spot.kingdom;
34 | spot.breathe();
35 |
36 | // from Dog prototype
37 | spot.bark();
38 | spot.species;
39 |
40 | // from Dog properties
41 | spot.name;
42 | spot.breed;
43 |
--------------------------------------------------------------------------------
/04-04-dom-and-jquery-continued/solution-code/pixart_js/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 GA_DC Campus
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/04-04-dom-and-jquery-continued/starter-code/pixart_js/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 GA_DC Campus
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/04-13-async-js-and-callbacks/solution-code/functions-callbacks-exercise/main.js:
--------------------------------------------------------------------------------
1 |
2 | // This function takes one parameter - predicate.
3 | // Predicate should be a function
4 | function countWhereTrue (predicate) {
5 | return function(items) {
6 | var count = 0;
7 | for (var i = 0; i < items.length; i++) {
8 | if (predicate(items[i])) {
9 | count++;
10 | }
11 | }
12 | return count;
13 | };
14 | }
15 |
16 | // This function should return true or false depending on if the number
17 | // passed to it is odd or not
18 | function isOdd(number) {
19 | return number % 2 !== 0;
20 | }
21 |
22 | /* Once you've filled in the two function definitions above, the line below should package up 'makeCountWhereTrue()' and 'isOdd()' into a single function that accepts an array of items as a parameter, loops through it and returns a count of how many of those items are odd numbers. This new function is being assigned to the variable 'countTheOdds'. */
23 | var countTheOdds = countWhereTrue(isOdd);
24 |
25 | /* The final line below calls our new 'countTheOdds()' function and passes in an array of numbers. Once your code is working, the line below should return the number 4. */
26 |
27 | console.log(countTheOdds([1, 2, 3, 4, 5, 6, 7]));
28 |
--------------------------------------------------------------------------------
/04-13-async-js-and-callbacks/starter-code/functions-callbacks-exercise/main.js:
--------------------------------------------------------------------------------
1 |
2 | function countWhereTrue (predicate) {
3 | // return a function that takes one parameter (an array)
4 | // Initialize a counter
5 | // For every item in the array
6 | // pass the item to the given predicate function
7 | // if the result of the prediciate function is true
8 | // increment the counter by 1
9 | // return the count
10 | }
11 |
12 | // This function should return true or false depending on if the number
13 | // passed to it is odd or not
14 | function isOdd(number) {
15 |
16 | }
17 |
18 | // Once you've filled in the two function definitions above, the line below
19 | // should package up 'countWhereTrue()' and 'isOdd()' into a single function that
20 | // accepts an array of items as a parameter, loops through it and returns a count
21 | // of how many of those items are odd numbers.
22 | // This new function is being assigned to the variable 'countTheOdds'.
23 | var countTheOdds = countWhereTrue(isOdd);
24 |
25 | // The final line below calls our new 'countTheOdds()' function and passes in an
26 | // array of numbers. Once your code is working, the line below should return
27 | // the number 4
28 | console.log( countTheOdds([1, 2, 3, 4, 5, 6, 7]) );
29 |
--------------------------------------------------------------------------------
/04-06-review/starter-code/cash-register/css/main.css:
--------------------------------------------------------------------------------
1 | body {
2 | background: #EEE;
3 | font-family: sans-serif;
4 | font-size: 20px;
5 | margin: 3em;
6 | padding: 0;
7 | }
8 |
9 | #register {
10 | width: 20em;
11 | margin: auto;
12 | }
13 |
14 | #ticket {
15 | background: white;
16 | margin: 0 1em;
17 | padding: 1em;
18 | box-shadow: 0 0 5px rgba(0,0,0,.25);
19 | }
20 | #ticket h1 {
21 | text-align: center;
22 | }
23 | #ticket table {
24 | font-family: monospace;
25 | width: 100%;
26 | border-collapse: collapse;
27 | }
28 | #ticket td, #ticket th {
29 | padding: 5px;
30 | }
31 | #ticket th {
32 | text-align: left;
33 | }
34 | #ticket td, #ticket #total {
35 | text-align: right;
36 | }
37 | #ticket tfoot th {
38 | border-top: 1px solid black;
39 | }
40 |
41 | #entry {
42 | background: #333;
43 | padding: 12px;
44 | border-radius: 10px;
45 | box-shadow: 0 0 5px rgba(0,0,0,.25);
46 | }
47 | #entry input {
48 | width: 100%;
49 | padding: 10px;
50 | border: 1px solid black;
51 | text-align: right;
52 | font-family: sans-serif;
53 | font-size: 20px;
54 | box-shadow: inset 0 0 3px rgba(0,0,0,.5);
55 | -webkit-box-sizing: border-box;
56 | -moz-box-sizing: border-box;
57 | box-sizing: border-box;
58 | }
59 | #entry input:focus {
60 | outline: none;
61 | border-color: rgba(255,255,255,.75);
62 | }
--------------------------------------------------------------------------------
/04-06-review/starter-code/cash-register/obfuscated/css/main.css:
--------------------------------------------------------------------------------
1 | body {
2 | background: #EEE;
3 | font-family: sans-serif;
4 | font-size: 20px;
5 | margin: 3em;
6 | padding: 0;
7 | }
8 |
9 | #register {
10 | width: 20em;
11 | margin: auto;
12 | }
13 |
14 | #ticket {
15 | background: white;
16 | margin: 0 1em;
17 | padding: 1em;
18 | box-shadow: 0 0 5px rgba(0,0,0,.25);
19 | }
20 | #ticket h1 {
21 | text-align: center;
22 | }
23 | #ticket table {
24 | font-family: monospace;
25 | width: 100%;
26 | border-collapse: collapse;
27 | }
28 | #ticket td, #ticket th {
29 | padding: 5px;
30 | }
31 | #ticket th {
32 | text-align: left;
33 | }
34 | #ticket td, #ticket #total {
35 | text-align: right;
36 | }
37 | #ticket tfoot th {
38 | border-top: 1px solid black;
39 | }
40 |
41 | #entry {
42 | background: #333;
43 | padding: 12px;
44 | border-radius: 10px;
45 | box-shadow: 0 0 5px rgba(0,0,0,.25);
46 | }
47 | #entry input {
48 | width: 100%;
49 | padding: 10px;
50 | border: 1px solid black;
51 | text-align: right;
52 | font-family: sans-serif;
53 | font-size: 20px;
54 | box-shadow: inset 0 0 3px rgba(0,0,0,.5);
55 | -webkit-box-sizing: border-box;
56 | -moz-box-sizing: border-box;
57 | box-sizing: border-box;
58 | }
59 | #entry input:focus {
60 | outline: none;
61 | border-color: rgba(255,255,255,.75);
62 | }
--------------------------------------------------------------------------------
/04-04-dom-and-jquery-continued/starter-code/pixart_js/pixart.js:
--------------------------------------------------------------------------------
1 | // Step 1
2 | //When I click the "Set Color" button, it should change the color of the "brush" box to the color I specify in the input field. (Hint: You will need to use event.preventDefault() somewhere in your code.)
3 |
4 | // Step 2
5 | //The same thing should happen when I press the enter key from inside the input field
6 |
7 | // Step 3
8 | //Create 20 divs of the "square" class and append them to the body
9 | //Hint: use .append()
10 |
11 | // Step 4
12 | //Add functionality so that when I click on each "square", it changes the color of that individual square to "green"
13 | //Hint: either add the event listener while creating the squares, or listen for events on the body element
14 |
15 | // Step 5
16 | //Modify your code so that when I click on each "square", it changes to the color I set using my input instead of "green" every time.
17 |
18 | // Step 6
19 | //Modify the CSS so that the "square" class has a height and width of 10px and a margin of 0.
20 | //Modify your code so that you are creating 8000 divs instead of 20.
21 | //Change the event that changes your box colors from 'click' to 'mouseover'
22 | //Paint a picture!
23 |
24 | // Bonus
25 | //Add a color swatch. You should have 3 boxes with the most recent 3 colors used. When you click on each of those boxes, it should set the current brush color back to that color.
26 |
--------------------------------------------------------------------------------
/03-23-project-1/starter_code/scripts/slackbot.js:
--------------------------------------------------------------------------------
1 | // Description:
2 | //
3 | //
4 | // Dependencies:
5 | // None
6 | //
7 | // Configuration:
8 | // None
9 | //
10 | // Commands:
11 | //
12 |
13 | module.exports = function(robot) {
14 | // YOUR CODE HERE
15 | // Example
16 | robot.hear(/javascript/i, function(msg) {
17 | return msg.send("I love JavaScript!");
18 | });
19 | }
20 |
21 | /************************************
22 |
23 | EXAMPLES OF THE KEY HUBOT FUNCTIONS
24 |
25 | ************************************/
26 |
27 | /* Variables for random example */
28 |
29 | var squirrels;
30 | squirrels = ["http://img.skitch.com/20100714-d6q52xajfh4cimxr3888yb77ru.jpg", "https://img.skitch.com/20111026-r2wsngtu4jftwxmsytdke6arwd.png", "http://cl.ly/1i0s1r3t2s2G3P1N3t3M/Screen_Shot_2011-10-27_at_9.36.45_AM.png", "http://shipitsquirrel.github.com/images/squirrel.png"];
31 |
32 | module.exports = function(robot) {
33 | /* Basic example of respond / send. If the user enters hi or hello the bot responds "Howdy!" */
34 | return robot.respond(/hi|hello/i, function(msg) {
35 | return msg.send("Howdy!");
36 | });
37 |
38 | /* Random Example
39 | If a user enters 'ship it' we return a random squirrel, which is popular for symbolizing shipping something with engineers */
40 | return robot.hear(/ship it/i, function(msg) {
41 | return msg.send(msg.random(squirrels));
42 | });
43 | };
44 |
--------------------------------------------------------------------------------
/03-21-functions-and-scope/starter-code/dice/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Dice Roller
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
Configure your APP_ID, APP_KEY and APP_HOST right here!
9 |
15 |
16 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/03-30-dom-and-jquery/starter-code/jquery_exercise/main.js:
--------------------------------------------------------------------------------
1 | /*Create a Checklist: Independent Practice
2 |
3 | You'll add the ability to complete tasks in your favorite things list. Your program must complete the following rules:
4 |
5 | - Through jQuery, add a "complete task" link at the end of each to-do item (i.e. each "favorite thing").
6 | - When clicked, the link will cross out the current item (hint: add a class to the list that sets the text-decoration to strikeout).
7 | - Each new item added by the user needs to also have the "complete task" link at the end.
8 | - Bonus: when user completes an item, remove that item from the current list and add it to a completed list below. Do not show this list unless the there are completed items.
9 | - Bonus 2: add the ability to restore items from the completed list to the first list.
10 |
11 | */
12 |
13 | 'use strict';
14 |
15 | $(function() {
16 | var yourName = prompt('What is your name?');
17 |
18 | $('#name').html(yourName);
19 |
20 | var $thingList = $('#fav-list');
21 |
22 | var $button = $('#new-thing-button');
23 | // button.onclick = function(event) {
24 | $button.on('click', function(event) {
25 | event.preventDefault();
26 | MyApp.addToList($thingList);
27 | });
28 | });
29 |
30 | var MyApp = {};
31 |
32 | MyApp.addToList = function(list) {
33 | var $newLi = $('
');
34 | var $newItemText = $('#new-thing');
35 | $newLi.html($newItemText.val());
36 | $newItemText.val('');
37 | if ($newLi.html() !== '') {
38 | list.append($newLi);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/03-16-collections-and-loops/starter-code/fizzbuzz.js:
--------------------------------------------------------------------------------
1 | /**
2 | * FizzBuzz Excercise
3 |
4 | Relying on newfound knowledge of loops, combine loops and if/else statements together and incrementally build the common fizzbuzz loop.
5 |
6 | - In the loop every time a number is divisible by **3**, instead of logging the number itself, the word "fizz" should appear.
7 | - If the number is divisible by **5**, the word "buzz" should be logged.
8 | - If the number is divisible by both **3** and **5**, then the word "fizzbuzz" should be logged.
9 |
10 | Follow the steps below.
11 |
12 | ##### Step 1:
13 | Construct a for loop that iterates through, and `console.log()`'s out, numbers 1 - 100.
14 |
15 |
16 |
17 | ##### Step 2:
18 | Add an `if/else` statement that logs the string `"fizz"` if the value being iterated over is divisible by `3`; otherwise, log out the value.
19 |
20 |
21 |
22 | ##### Step 3:
23 | Add an `else if` clause that logs the string `"buzz"` if the value being iterated over is divisible by `5`.
24 |
25 |
26 |
27 | ##### Step 4:
28 | Add an additional `else if` clause that logs the string `"fizzbuzz"` if the value being iterated over is divisible by both `3` and `5`. __Note:__ this step is intentionally broken! Place the new `else if` __below__ the evaluations for `fizz` and `buzz`; after running the code, and experiencing the undesired results, prompt the students as to why the `fizzbuzz` evaluation never occurred.
29 |
30 |
31 | ##### Step 5:
32 | Fix the above code to evaluate the `fizzbuzz` condition:
33 |
34 |
35 | */
36 |
--------------------------------------------------------------------------------
/05-04-CRUD/solution-code/config.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
Configure your APP_ID, APP_KEY and APP_HOST right here!
9 |
Configure your APP_ID, APP_KEY and APP_HOST right here!
9 |
15 |
16 |
17 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | #  JavaScript Development
2 |
3 | ## People
4 |
5 | - Producer
6 | - Tim Foley
7 | - [tim.foley@ga.co](tim.foley@ga.co)
8 | - 202-748-3694
9 | - Instructors
10 | - Johnny Austin
11 | - [johnny@isl.co](johnny@isl.co)
12 | - Office hours:
13 | - Thursdays 6:00pm -8:00pm [ISL Office](https://isl.co/contact/)
14 | - Jesse Shawl
15 | - [jesse@ga.co](jesse@ga.co)
16 | - office hours:
17 | - Sundays 10:00am - 12:00pm @ GA
18 | - TA
19 | - John Master
20 | - [john.master@generalassemb.ly](john.master@generalassemb.ly)
21 | - Office hours:
22 | - Monday 5:30 - 6:30 (General Assembly)
23 | - Wednesday 5:30 - 6:30 (General Assembly)
24 |
25 | ## Course information
26 |
27 | Class will meet on the 8th floor in classroom 3 from 6:30 - 9:30pm - https://goo.gl/maps/PwyY2
28 |
29 | To get up to the 8th floor, show the attached Class Pass at the Security Desk downstairs. You will need to show this on your phone or printed out every time.
30 | Once you're upstairs, tell the folks at the front desk you're here for your first day of Javascript and they'll point you to your classroom.
31 |
32 | ### What to Bring
33 |
34 | A. Your laptop (and charger with your name on it!)
35 |
36 | B. Snacks in case you get hungry
37 |
38 | C. [Class Pass](./assets/class-pass.png) printed out or on your phone
39 |
40 | ## Schedule
41 |
42 | [Google Calendar](https://calendar.google.com/calendar/embed?src=generalassemb.ly_2bpe0sg92jg3otj03epjk03foc%40group.calendar.google.com&ctz=America/New_York)
43 |
--------------------------------------------------------------------------------
/03-14-data-types/lab.md:
--------------------------------------------------------------------------------
1 | ## Data Collections
2 |
3 | ### Arrays
4 |
5 | Javascript provides us with a number of native methods that allow us to interact with arrays. Find methods that do each of the following and provide an example...
6 | * Add an element to the back of an array.
7 | * Remove an element from the back of an array.
8 | * Add an element to the front of an array.
9 | * Remove an element from the front of an array.
10 | * Concatenates all the elements in an array into a string.
11 | * Separates the characters of a string into an array.
12 |
13 | ```js
14 | // Your answers go here.
15 | ```
16 |
17 | What will the contents of the below arrays be after the code samples are executed? Come up with an answer yourself before testing it out in the console.
18 | > **HINT:** You might find it helpful to draw the arrays out as you run each line of code.
19 |
20 | ```js
21 | var numbers = [ 2, 4, 6, 8 ];
22 | numbers.pop();
23 | numbers.push( 10 );
24 | numbers.unshift( 3 );
25 | ```
26 |
27 | ```
28 | Your answer goes here.
29 | ```
30 |
31 | What is the return value of the below code sample? Come up with an answer yourself before testing it out in the console.
32 |
33 | ```js
34 | var morse = [ "dot", "pause", "dot" ];
35 | var moreMorse = morse.join( " dash " );
36 | moreMorse.split( " " );
37 | ```
38 |
39 | ```
40 | Your answer goes here.
41 | ```
42 |
43 | What will the contents of the below array be after the below code sample is executed? Come up with an answer yourself before testing it out in the console.
44 |
45 | ```js
46 | var bands = [];
47 | var beatles = [ "Paul", "John", "George", "Pete" ];
48 | var stones = [ "Brian", "Mick", "Keith", "Ronnie", "Charlie" ];
49 | bands.push( beatles );
50 | bands.unshift( stones );
51 | bands[ bands.length - 1 ].pop();
52 | bands[0].shift();
53 | bands[1][3] = "Ringo";
54 | ```
55 |
56 | ```
57 | Your answer goes here.
58 | ```
59 |
--------------------------------------------------------------------------------
/04-18-advanced-apis/solution-code/app.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | // get access token from hash/fragment
4 | var uriHash = window.location.hash;
5 |
6 | if (uriHash.length > 0) {
7 | var accessToken = uriHash.replace('#access_token=', '');
8 | getImages(accessToken);
9 | } else {
10 | // if not yet redirected hide results view
11 | $('.image-results-view').hide();
12 | }
13 |
14 | function getImages(accessToken) {
15 | // if redirected hide initial view
16 | $('.sign-in-view').hide();
17 |
18 | // use the navigator given to us by the window.navigator object to find the user's location
19 | getCurrentLocation(function(position) {
20 | var lat = position.coords.latitude;
21 | var lng = position.coords.longitude;
22 |
23 | // configure instagram endpoint with accessToken and user's location data
24 | var instagramEndpoint = 'https://api.instagram.com/v1/media/search?lat=' + lat + '&lng=' + lng + '&access_token=' + accessToken
25 |
26 | // call the instagram with configured URI
27 | $.ajax({
28 | url: instagramEndpoint,
29 | method: 'GET',
30 | dataType: 'jsonp',
31 | success: handleResponseSuccess
32 | });
33 | });
34 |
35 | }
36 |
37 | function handleResponseSuccess(response) {
38 | var allData = response.data;
39 |
40 | // iterate through each piece of data
41 | allData.forEach(function(data) {
42 | var imageUrl = 'url(' + data.images.standard_resolution.url + ')';
43 |
44 | // create element
45 | var element = $('').css({'background-image': imageUrl}).addClass('image');
46 |
47 | // append element to .images node
48 | $('.images').append(element);
49 | });
50 | }
51 |
52 | function getCurrentLocation(onLocation) {
53 | if (navigator.geolocation) {
54 | navigator.geolocation.getCurrentPosition(onLocation);
55 | } else {
56 | console.error("Geolocation is not supported by this browser.");
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/04-06-review/starter-code/atm/readme.md:
--------------------------------------------------------------------------------
1 | #ATM application
2 |
3 | We 're going to build an application to keep track of the checking and savings balances.
4 |
5 | There is also a vanilla Javascript solution branch that was coded in class.
6 |
7 | ## USE jQUERY
8 |
9 | ###User Stories
10 | - As a user, I want to deposit money into one of the bank accounts
11 | - As a user, I want to withdraw money from one of the bank accounts
12 | - Make sure the balance in an account can't go negative. If a user tries to withdraw more money than exists in the account, ignore the transaction.
13 | - As a user, I want overdraft protection
14 | - What happens when the user wants to withdraw more money from the checking account than is in the account?
15 | - If a withdrawal can be covered by the balances in both accounts, take the balance of the account withdrawn from down to $0 and take the rest of the withdrawal from the other account.
16 | - If the withdrawal amount is more than the combined account balance, ignore it.
17 | - As a user, I want the color of my back account to reflect it's balance (there's a CSS class called .zero already written for this!)
18 | - Are there ways to refactor your code to make it DRYer or more Object-Oriented?
19 |
20 | ###Tips
21 | * Tackle making your accounts work individually first
22 | * Then tackle them working together with overdraft protection
23 | * Only start working with the DOM after you have the logic down
24 |
25 | ###Resources
26 | * [What is window.onload for?](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers.onload)
27 | * [Adding Event Listeners so things happen when you click](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener)
28 | * [Adding or removing a CSS class using JS](https://developer.mozilla.org/en-US/docs/Web/API/Element.classList)
29 | * [Changing HTML with JavaScript](https://developer.mozilla.org/en-US/docs/Web/API/Element.innerHTML)
30 |
--------------------------------------------------------------------------------
/04-04-dom-and-jquery-continued/solution-code/pixart_js/pixart.js:
--------------------------------------------------------------------------------
1 | var $button = $("#set-color");
2 | var $brush = $(".brush");
3 | var $input = $("#color-field");
4 | var $form = $("#form");
5 | var $body = $("body");
6 |
7 | // Step 1
8 | //When I click the "Set Color" button, it should change the color of the "brush" box to the color I specify in the input field. (Hint: You will need to use event.preventDefault() somewhere in your code.)
9 | $form.on("submit", function(e){
10 | e.preventDefault();
11 | var color = $input.val();
12 | $brush.css('background', color);
13 | })
14 |
15 | // Step 2
16 | //The same thing should happen when I press the enter key from inside the input field
17 |
18 | // Step 3
19 | //Create 20 divs of the "square" class and append them to the body
20 | //Hint: use .append()
21 |
22 | for( var i = 0; i < 8000; i++){
23 | $body.append("");
24 | }
25 |
26 | // Step 4
27 | //Add functionality so that when I click on each "square", it changes the color of that individual square to "green"
28 | //Hint: either add the event listener while creating the squares, or listen for events on the body element
29 |
30 | $(".square").on("mouseover", function( event ){
31 | var $square = $(event.target);
32 | $square.css('background',$input.val())
33 | })
34 |
35 | // Step 5
36 | //Modify your code so that when I click on each "square", it changes to the color I set using my input instead of "green" every time.
37 |
38 | // Step 6
39 | //Modify the CSS so that the "square" class has a height and width of 10px and a margin of 0.
40 | //Modify your code so that you are creating 8000 divs instead of 20.
41 | //Change the event that changes your box colors from 'click' to 'mouseover'
42 | //Paint a picture!
43 |
44 | // Bonus
45 | //Add a color swatch. You should have 3 boxes with the most recent 3 colors used. When you click on each of those boxes, it should set the current brush color back to that color.
46 |
--------------------------------------------------------------------------------
/04-04-dom-and-jquery-continued/solution-code/pixart_js/README.md:
--------------------------------------------------------------------------------
1 | #Pixart
2 |
3 | Use the starter code and commit each step of the exercise.
4 |
5 | - Fork and clone this repo.
6 | - Checkout a new branch called '**YOUR-NAME**-solution'
7 | - Work in small steps and commit frequently.
8 | - When you're finished, push your solution branch to your fork (`git push origin `) and issue a **pull request**.
9 | - Feel free to use jQuery.
10 |
11 | ###Commit 1
12 |
13 | * When I click the "Set Color" button, it should change the color of the "brush" box to the color I specify in the input field. (**Hint:** You will need to use `event.preventDefault()` somewhere in your code.)
14 | * Use jQuery to select the element, and `addEventListener` to handle clicks
15 | * `$("body")[0].addEventListener...`
16 |
17 | ###Commit 2
18 |
19 | * The same thing should happen when I press the enter key from inside the input field
20 |
21 | ###Commit 3
22 |
23 | * Create 20 divs of the "square" class and append them to the body
24 | * **Hint**: use `.append()`
25 |
26 | ###Commit 4
27 |
28 | * Add functionality so that when I click on each "square", it changes the color of that individual square to "green"
29 | * **Hint**: either add the event listener while creating the squares, or listen for events on the `body` element
30 |
31 | ###Commit 5
32 |
33 | * Modify your code so that when I click on each "square", it changes to the color I set using my input instead of "green" every time.
34 |
35 | ###Commit 6
36 |
37 | * Modify the CSS so that the "square" class has a height and width of 10px and a margin of 0.
38 | * Modify your code so that you are creating 8000 divs instead of 20.
39 | * Change the event that changes your box colors from 'click' to 'mouseover'
40 | * Paint a picture!
41 |
42 | ## Bonus
43 |
44 | * Add a color swatch. You should have 3 boxes with the most recent 3 colors used. When you click on each of those boxes, it should set the current brush color back to that color.
45 |
--------------------------------------------------------------------------------
/04-04-dom-and-jquery-continued/starter-code/pixart_js/README.md:
--------------------------------------------------------------------------------
1 | #Pixart
2 |
3 | Use the starter code and commit each step of the exercise.
4 |
5 | - Fork and clone this repo.
6 | - Checkout a new branch called '**YOUR-NAME**-solution'
7 | - Work in small steps and commit frequently.
8 | - When you're finished, push your solution branch to your fork (`git push origin `) and issue a **pull request**.
9 | - Feel free to use jQuery.
10 |
11 | ###Commit 1
12 |
13 | * When I click the "Set Color" button, it should change the color of the "brush" box to the color I specify in the input field. (**Hint:** You will need to use `event.preventDefault()` somewhere in your code.)
14 | * Use jQuery to select the element, and `addEventListener` to handle clicks
15 | * `$("body")[0].addEventListener...`
16 |
17 | ###Commit 2
18 |
19 | * The same thing should happen when I press the enter key from inside the input field
20 |
21 | ###Commit 3
22 |
23 | * Create 20 divs of the "square" class and append them to the body
24 | * **Hint**: use `.append()`
25 |
26 | ###Commit 4
27 |
28 | * Add functionality so that when I click on each "square", it changes the color of that individual square to "green"
29 | * **Hint**: either add the event listener while creating the squares, or listen for events on the `body` element
30 |
31 | ###Commit 5
32 |
33 | * Modify your code so that when I click on each "square", it changes to the color I set using my input instead of "green" every time.
34 |
35 | ###Commit 6
36 |
37 | * Modify the CSS so that the "square" class has a height and width of 10px and a margin of 0.
38 | * Modify your code so that you are creating 8000 divs instead of 20.
39 | * Change the event that changes your box colors from 'click' to 'mouseover'
40 | * Paint a picture!
41 |
42 | ## Bonus
43 |
44 | * Add a color swatch. You should have 3 boxes with the most recent 3 colors used. When you click on each of those boxes, it should set the current brush color back to that color.
45 |
--------------------------------------------------------------------------------
/04-04-dom-and-jquery-continued/solution-code/events_codealong_and_exercise/main.js:
--------------------------------------------------------------------------------
1 |
2 | //SOLUTION: Appending: Independent Practice
3 |
4 | 'use strict';
5 | var MyApp = {};
6 |
7 | MyApp.addToList = function(list) {
8 | var $newLi = $('
');
9 | var $newItemText = $('#new-thing');
10 | $newLi.html($newItemText.val());
11 | $newItemText.val('');
12 | if ($newLi.html() !== '') {
13 | list.append($newLi);
14 | }
15 | MyApp.addButtons($newLi);
16 | }
17 |
18 | MyApp.initiateButtons = function($thingList) {
19 | $thingList.find('li').each(function() {
20 | MyApp.addButtons($(this));
21 | });
22 | }
23 |
24 | MyApp.addButtons = function($item) {
25 | var completeBtn = ' Complete';
26 | $item.append(completeBtn);
27 |
28 | var deleteBtn = ' Delete';
29 | $item.append(deleteBtn);
30 | }
31 |
32 | $(function() {
33 | // var yourName = prompt('What is your name?');
34 |
35 | $('#name').html("World");
36 |
37 | var $thingList = $('#fav-list');
38 |
39 | var $button = $('#new-thing-button');
40 | // button.onclick = function(event) {
41 | $button.on('click', function(event) {
42 | event.preventDefault();
43 | MyApp.addToList($thingList);
44 | });
45 |
46 |
47 | $thingList.on('mouseenter mouseleave', 'li', function(event) {
48 | if (event.type == 'mouseenter') {
49 | $(this).removeClass('inactive');
50 | $(this).siblings().addClass('inactive');
51 | } else if (event.type == 'mouseleave') {
52 | $(this).siblings().removeClass('inactive');
53 | }
54 | });
55 |
56 | $thingList.on('click', 'a.complete', function(e) {
57 | e.preventDefault();
58 | var listItem = $(this).parent('li');
59 |
60 | listItem.toggleClass('completed');
61 | });
62 |
63 | $thingList.on('click', 'a.delete', function(e) {
64 | e.preventDefault();
65 | $(this).parent('li').remove();
66 | });
67 |
68 | MyApp.initiateButtons($thingList);
69 | });
70 |
--------------------------------------------------------------------------------
/04-18-advanced-apis/starter-code/app.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | // get access token from hash/fragment
4 | var uriHash = window.location.hash;
5 |
6 | if (uriHash.length > 0) {
7 | var accessToken = uriHash.replace('#access_token=', '');
8 | getImages(accessToken);
9 | } else {
10 | // if not yet redirected hide results view
11 | $('.image-results-view').hide();
12 | }
13 |
14 |
15 | function getImages(accessToken) {
16 | // hide the sign in view
17 |
18 |
19 | // Determine the user's location. When the location position is obtained
20 | // store latitude in a variable
21 | // store longitude in a variable
22 |
23 | // create a variable for the endpoing
24 | var instagramEndpoint = ``; // <== store your url here in this string!
25 |
26 | // now lets fetch the data images from instagram and handle the response
27 | $ajax({
28 | url: instagramEndpoint,
29 | method: '', // <=== Hmm, what type of request is this?,
30 | dataType: 'jsonp',
31 | success: handleResponseSuccess // <== You'll have to implement this below
32 | });
33 | }
34 |
35 |
36 | function handleResponseSuccess(response) {
37 | var allData = response.data;
38 | // for each item in allData
39 | // assign the item's image url to a variable imageUrl
40 | // create a new jQuery div element
41 | // Use the jQuery css method to change the background of the the div to the imageUrl
42 | // Use jQuery to add the 'image' class to the new div element
43 | // append the new div element to the .images div
44 | }
45 |
46 | // This function fetches the current location of the user. It has one parameter
47 | // onLocation which is a callback function here's an example
48 | // getCurrentLocation(function(position) {
49 | // the position object has the current lat/long
50 | // })
51 | function getCurrentLocation(onLocation) {
52 | if (navigator.geolocation) {
53 | navigator.geolocation.getCurrentPosition(onLocation);
54 | } else {
55 | console.error("Geolocation is not supported by this browser.");
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/03-16-collections-and-loops/solution-code/fizzbizz.js:
--------------------------------------------------------------------------------
1 | //Step 1:
2 |
3 | //Construct a for loop that iterates through, and `console.log()`'s out, numbers 1 - 100:
4 |
5 | for (var num = 1; num <= 100; num++) {
6 | console.log(num);
7 | }
8 |
9 | //Step 2:
10 |
11 | //Add an `if/else` statement that logs the string `"fizz"` if the value being iterated over is divisible by `3`; otherwise, log out the value:
12 |
13 | for (var num = 1; num <= 100; num++) {
14 | if (num % 3 === 0) {
15 | console.log('fizz');
16 | } else {
17 | console.log(num)
18 | }
19 | }
20 |
21 | //##### Step 3:
22 |
23 | //Add an `else if` clause that logs the string `"buzz"` if the value being iterated over is divisible by `5`:
24 |
25 | for (var num = 1; num <= 100; num++) {
26 | if (num % 3 === 0) {
27 | console.log('fizz');
28 | } else if (num % 5 === 0) {
29 | console.log('buzz')
30 | } else {
31 | console.log(num)
32 | }
33 | }
34 |
35 | //##### Step 4:
36 |
37 | //Add an additional `else if` clause that logs the string `"fizzbuzz"` if the value being iterated over is divisible by both `3` and `5`. __Note:__ this step is intentionally broken! Place the new `else if` __below__ the evaluations for `fizz` and `buzz`; after running the code, and experiencing the undesired results, prompt the students as to why the `fizzbuzz` evaluation never occurred.
38 |
39 | for (var num = 1; num <= 100; num++) {
40 | if (num % 3 === 0) {
41 | console.log('fizz');
42 | } else if (num % 5 === 0) {
43 | console.log('buzz')
44 | } else if (num % 15 === 0) {
45 | console.log('fizzbuzz')
46 | } else {
47 | console.log(num)
48 | }
49 | }
50 |
51 | //##### Step 5:
52 |
53 | //Fix the above code to evaluate the `fizzbuzz` condition:
54 |
55 |
56 | for (var num = 1; num <= 100; num++) {
57 | if (num % 15 === 0) {
58 | console.log('fizzbuzz');
59 | } else if (num % 5 === 0) {
60 | console.log('buzz')
61 | } else if (num % 3 === 0) {
62 | console.log('fizz')
63 | } else {
64 | console.log(num)
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/05-02-prototypal-inheritance/solution-code/07-oop-monkey-js/spec/monkey_spec.js:
--------------------------------------------------------------------------------
1 | var jasmineExpect = require('jasmine-expect');
2 | var Monkey = require("../lib/monkey.js");
3 |
4 | describe("Monkey", function() {
5 | it("has a name", function() {
6 | adam = new Monkey("Adam", "Spider Monkey");
7 |
8 | expect(adam.name).toEqual("Adam");
9 | });
10 |
11 | it("has a species", function() {
12 | andy = new Monkey("Andy", "Cool Monkey");
13 |
14 | expect(andy.species).toEqual("Cool Monkey");
15 | });
16 |
17 | it("starts with no foods eaten", function() {
18 | adrian = new Monkey("Adrian", "White-headed Capuchin");
19 |
20 | expect(adrian.foodsEaten).toEqual([]);
21 | });
22 |
23 | it("can eat a food (a string)", function() {
24 | matt = new Monkey("Matt", "Mandrill");
25 | matt.eat("banana");
26 | matt.eat("PB&J");
27 |
28 | expect(matt.foodsEaten).toContain("banana");
29 | expect(matt.foodsEaten).toContain("PB&J");
30 | });
31 |
32 | it("can introduce itself with name, species, and foods eaten", function() {
33 | jesse = new Monkey("Jesse", "Dusky Leaf Monkey");
34 | jesse.eat("cheeseburger");
35 | jesse.eat("bacon");
36 |
37 | expect(jesse.introduce()).toContain("Jesse");
38 | expect(jesse.introduce()).toContain("Dusky Leaf Monkey");
39 | expect(jesse.introduce()).toContain("cheeseburger");
40 | expect(jesse.introduce()).toContain("bacon");
41 | });
42 |
43 | // //******BONUS******
44 | // it("always has a capitalized name", function() {
45 | // robin = new Monkey("robin", "Olive Baboon");
46 | // expect(robin.name).toEqual("Robin");
47 | // });
48 | //
49 | // it("won't eat foods begninng with a vowel", function() {
50 | // robin = new Monkey("robin", "Olive Baboon");
51 | //
52 | // robin.eat("apple");
53 | // robin.eat("eclair");
54 | // robin.eat("ice");
55 | // robin.eat("ovaltine");
56 | // robin.eat("udon");
57 | //
58 | // robin.eat("pudding");
59 | // robin.eat("chocolate");
60 | //
61 | // //we only expect to see non-vowel foods in the list of foodsEaten
62 | // expect(robin.foodsEaten).toEqual(["pudding", "chocolate"]);
63 | // });
64 | });
65 |
--------------------------------------------------------------------------------
/05-02-prototypal-inheritance/starter-code/07-oop-monkey-js/spec/monkey_spec.js:
--------------------------------------------------------------------------------
1 | var jasmineExpect = require('jasmine-expect');
2 | var Monkey = require("../lib/monkey.js");
3 |
4 | describe("Monkey", function() {
5 | it("has a name", function() {
6 | adam = new Monkey("Adam", "Spider Monkey");
7 |
8 | expect(adam.name).toEqual("Adam");
9 | });
10 |
11 | it("has a species", function() {
12 | andy = new Monkey("Andy", "Cool Monkey");
13 |
14 | expect(andy.species).toEqual("Cool Monkey");
15 | });
16 |
17 | it("starts with no foods eaten", function() {
18 | adrian = new Monkey("Adrian", "White-headed Capuchin");
19 |
20 | expect(adrian.foodsEaten).toEqual([]);
21 | });
22 |
23 | it("can eat a food (a string)", function() {
24 | matt = new Monkey("Matt", "Mandrill");
25 | matt.eat("banana");
26 | matt.eat("PB&J");
27 |
28 | expect(matt.foodsEaten).toContain("banana");
29 | expect(matt.foodsEaten).toContain("PB&J");
30 | });
31 |
32 | it("can introduce itself with name, species, and foods eaten", function() {
33 | jesse = new Monkey("Jesse", "Dusky Leaf Monkey");
34 | jesse.eat("cheeseburger");
35 | jesse.eat("bacon");
36 |
37 | expect(jesse.introduce()).toContain("Jesse");
38 | expect(jesse.introduce()).toContain("Dusky Leaf Monkey");
39 | expect(jesse.introduce()).toContain("cheeseburger");
40 | expect(jesse.introduce()).toContain("bacon");
41 | });
42 |
43 | // //******BONUS******
44 | // it("always has a capitalized name", function() {
45 | // robin = new Monkey("robin", "Olive Baboon");
46 | // expect(robin.name).toEqual("Robin");
47 | // });
48 | //
49 | // it("won't eat foods begninng with a vowel", function() {
50 | // robin = new Monkey("robin", "Olive Baboon");
51 | //
52 | // robin.eat("apple");
53 | // robin.eat("eclair");
54 | // robin.eat("ice");
55 | // robin.eat("ovaltine");
56 | // robin.eat("udon");
57 | //
58 | // robin.eat("pudding");
59 | // robin.eat("chocolate");
60 | //
61 | // //we only expect to see non-vowel foods in the list of foodsEaten
62 | // expect(robin.foodsEaten).toEqual(["pudding", "chocolate"]);
63 | // });
64 | });
65 |
--------------------------------------------------------------------------------
/04-13-async-js-and-callbacks/instagram.md:
--------------------------------------------------------------------------------
1 | # 
2 |
3 | #### Signing Up For Instagram Credentials
4 |
5 | In the next lesson, we'll be doing an in-class exercise that uses Instagram's API. The first step in working with a third-party API that requires authentication is to register your application with the API. The purpose of this is so that the API owner, in this case Instagram, can give our app credentials to use in future requests so it can recognize who is asking for what information. Let's go ahead and get our credentials!
6 |
7 | First and foremost, you must have an Instagram account. If you don't already have one, please sign up. Once you are signed in, visit Instagram's [developer site](https://instagram.com/developer/). Here you will see an option in the navbar to "Manage Clients". Click it. Once [here](https://instagram.com/developer/clients/manage/) register your application by clicking on the "Register a New Client" button. You should see the following:
8 |
9 | 
10 |
11 | After you fill out the form you'll have:
12 |
13 | 
14 |
15 | Most of the fields values should be pretty self-explanatory. However, _Website URL_ and _Valid Redirect URIs_ may not be as obvious. In both of these fields, enter in `http://localhost:3000`. Make sure you type in `http://localhost:3000` carefully, as the punctuation here matters!
16 |
17 | The last step is to turn on implicit Oauth flow, which we'll be needing for our app. Hit the "edit" button on your newly-created application. Next, hit the "security" button. You should see the screen below. What you're looking for is the checkbox that says "Disable implicit Oauth" next to it. **If this box is checked, make sure to uncheck it**. If you neglect to uncheck this box, your app will not work!
18 |
19 | 
20 |
21 | You're now ready to start working with the Instagram API during our next class!
22 |
--------------------------------------------------------------------------------
/04-11-ajax-and-apis/starter-code/03-posts_requests/main.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var FavoriteThings = {
4 | elements: {
5 | $thingList: $('#todo-list'),
6 | $button: $('#new-thing-button'),
7 | $form: $('#new-thing-form'),
8 | $newItemInput: $('#new-thing'),
9 | $toDoTemplate: $("#to-do-template")
10 | },
11 | add: function(thing){
12 | var $listItem = FavoriteThings.render(FavoriteThings.elements.$toDoTemplate,thing);
13 | FavoriteThings.elements.$thingList.append($listItem);
14 | FavoriteThings.elements.$newItemInput.val('');
15 | // send a post request to "/things"
16 | // data: { newThing: thing.text }
17 | },
18 | markComplete: function(event){
19 | event.preventDefault();
20 | $(this).parent().addClass("completed");
21 | var thing = $(this).siblings(".todo-text").html()
22 | // send a patch request to /things/thing-text
23 | // e.g. /things/
24 | },
25 | delete: function(event){
26 | event.preventDefault();
27 | $(this).parent().remove();
28 | // send a delete request to /thing
29 | // data: { thing: thing.text }
30 | },
31 | listen: function(){
32 | FavoriteThings.elements.$form.on("submit", function(event){
33 | event.preventDefault();
34 | FavoriteThings.add({
35 | text: FavoriteThings.elements.$newItemInput.val(),
36 | completed: false
37 | })
38 | })
39 | FavoriteThings.elements.$thingList.on(
40 | "click", 'a.complete',
41 | FavoriteThings.markComplete
42 | )
43 | FavoriteThings.elements.$thingList.on(
44 | "click", 'a.delete',
45 | FavoriteThings.delete
46 | )
47 | },
48 | render: function($element, context){
49 | var source = $element.html();
50 | var template = Handlebars.compile(source);
51 | var html = template(context);
52 | return $(html);
53 | },
54 | load: function(callback){
55 | $.get("/things", function(response){
56 | console.log(response)
57 | response.forEach(function(thing){
58 | FavoriteThings.elements.$thingList.append(
59 | FavoriteThings.render(FavoriteThings.elements.$toDoTemplate,thing)
60 | )
61 | })
62 | callback(response)
63 | })
64 | }
65 | };
66 |
67 | FavoriteThings.load(function(){
68 | FavoriteThings.listen()
69 | })
70 |
--------------------------------------------------------------------------------
/04-11-ajax-and-apis/solution-code/03-posts_requests/server.js:
--------------------------------------------------------------------------------
1 |
2 | 'use strict';
3 |
4 | var fs = require('fs');
5 | var express = require('express');
6 | var bodyParser = require('body-parser');
7 | var connect = require('connect');
8 | var app = express();
9 | var myFavThings = [];
10 |
11 | app.use(bodyParser());
12 | app.use(bodyParser.json());
13 | app.use(bodyParser.urlencoded({ extended: false }));
14 | app.use(express.static('.'));
15 |
16 | app.patch('/things/:existingThing', function(req, res) {
17 | var existingThing = req.params.existingThing;
18 | var completed = req.body.completed;
19 | var index = indexOf(existingThing);
20 | if (index > -1) {
21 | myFavThings[index].completed = completed;
22 | res.status(200).send(myFavThings);
23 | } else {
24 | res.status(500).send(`Thing ${existingThing} does not exist`);
25 | }
26 | });
27 |
28 | app.post('/things', function(req, res) {
29 | var newThing = req.body.newThing;
30 | if (!exists(newThing)) {
31 | myFavThings.push({ text: newThing, completed: false });
32 | res.status(200).json(newThing);
33 | } else {
34 | res.status(500).json({ message: `Thing ${newThing} is already in your list` });
35 | }
36 | })
37 |
38 | app.get('/things', function(req, res) {
39 | res.status(200).json(myFavThings);
40 | });
41 |
42 | app.delete('/thing', function(req, res) {
43 | var thingToDelete = req.body.thing;
44 | /*
45 | * Remove the thing from our favThings array and return
46 | * the new array with a status of 200. Use the app.post('/thing')
47 | * route as a guide.
48 | */
49 | });
50 |
51 | app.get('/', function(req, res) {
52 | fs.createReadStream('index.html').pipe(res);
53 | });
54 |
55 | app.listen(3000, function() {
56 | console.log('\n**********************************');
57 | console.log(` I believe in you :-)\n Go to http://localhost:3000`);
58 | console.log('**********************************\n');
59 | });
60 |
61 | function exists(thing) {
62 | return myFavThings.some(function(item) {
63 | return item.text === thing.text;
64 | });
65 | }
66 |
67 | function indexOf(thingText) {
68 | var index;
69 | for (var i = 0; i < myFavThings.length; i++) {
70 | if (thingText === myFavThings[i].text) {
71 | index = i;
72 | break;
73 | }
74 | }
75 | return index;
76 | }
--------------------------------------------------------------------------------
/04-11-ajax-and-apis/starter-code/03-posts_requests/server.js:
--------------------------------------------------------------------------------
1 |
2 | 'use strict';
3 |
4 | var fs = require('fs');
5 | var express = require('express');
6 | var bodyParser = require('body-parser');
7 | var connect = require('connect');
8 | var app = express();
9 | var myFavThings = [];
10 |
11 | app.use(bodyParser());
12 | app.use(bodyParser.json());
13 | app.use(bodyParser.urlencoded({ extended: false }));
14 | app.use(express.static('.'));
15 |
16 | app.patch('/things/:existingThing', function(req, res) {
17 | var existingThing = req.params.existingThing;
18 | var completed = req.body.completed;
19 | var index = indexOf(existingThing);
20 | if (index > -1) {
21 | myFavThings[index].completed = completed;
22 | res.status(200).send(myFavThings);
23 | } else {
24 | res.status(500).send(`Thing ${existingThing} does not exist`);
25 | }
26 | });
27 |
28 | app.post('/things', function(req, res) {
29 | var newThing = req.body.newThing;
30 | if (!exists(newThing)) {
31 | myFavThings.push({ text: newThing, completed: false });
32 | res.status(200).json(newThing);
33 | } else {
34 | res.status(500).json({ message: `Thing ${newThing} is already in your list` });
35 | }
36 | })
37 |
38 | app.get('/things', function(req, res) {
39 | res.status(200).json(myFavThings);
40 | });
41 |
42 | app.delete('/thing', function(req, res) {
43 | var thingToDelete = req.body.thing;
44 | /*
45 | * Remove the thing from our favThings array and return
46 | * the new array with a status of 200. Use the app.post('/thing')
47 | * route as a guide.
48 | */
49 | });
50 |
51 | app.get('/', function(req, res) {
52 | fs.createReadStream('index.html').pipe(res);
53 | });
54 |
55 | app.listen(3000, function() {
56 | console.log('\n**********************************');
57 | console.log(` I believe in you :-)\n Go to http://localhost:3000`);
58 | console.log('**********************************\n');
59 | });
60 |
61 | function exists(thing) {
62 | return myFavThings.some(function(item) {
63 | return item.text === thing.text;
64 | });
65 | }
66 |
67 | function indexOf(thingText) {
68 | var index;
69 | for (var i = 0; i < myFavThings.length; i++) {
70 | if (thingText === myFavThings[i].text) {
71 | index = i;
72 | break;
73 | }
74 | }
75 | return index;
76 | }
--------------------------------------------------------------------------------
/05-04-CRUD/starter-code/app.js:
--------------------------------------------------------------------------------
1 | /*
2 | ===================================================
3 | ===================== WELCOME =====================
4 | ===================================================
5 | */
6 |
7 | var Message = new ParseObjectType('Message');
8 |
9 | $(document).ready(function() {
10 | // TODO
11 | // When the message form submits
12 | // stop the page from refreshing
13 | // Take the data entered and create a new message. Relevant data is the message text and number of upVotes
14 | // When the message is SUCCESSFULLY created, grab the objectId from the result and render a new handlebars template
15 |
16 | // on initialization of app (when document is ready) get fan messages
17 | getFanMessages();
18 |
19 | // This function should get all the currently saved messages and setup the event listeners
20 | // for the upvote and delete button!
21 | function getFanMessages() {
22 |
23 | // TODO
24 | // When someone clicks an upvote button, increase the number of votes and update the corresponding message model
25 | // When someone clicks a delete button, remove that message from the database
26 | // Update the view to reflect the upvote or deletion
27 |
28 | // Maybe you can use this function to encapsulate the remote post functionality.
29 | // Maybe $messageEl is the corresponding li element. IDK, do what you want.
30 | function removePost($messageEl) {
31 | // TODO
32 | // Remove the message from the database. When it's done, update the view
33 | }
34 |
35 | // Maybe you can use this function to encapsulate the increment votes functionality.
36 | // Maybe $messageEl is the corresponding li element. IDK, do what you want.
37 | function updateVote($messageEl) {
38 | // TODO
39 | // Update the vote count in the database. When it's done, update the view
40 | }
41 |
42 | // TODO
43 | // There should be code here to get all the current messages and populate the view accordingly
44 | }
45 |
46 | function renderMessage(messageData) {
47 | var html = compile(messageData);
48 | $('.message-board').append(html);
49 | }
50 |
51 | function compile(messageData) {
52 | var source = $("#message-template").html();
53 | var template = Handlebars.compile(source);
54 | var html = template(messageData);
55 | return html;
56 | }
57 | });
58 |
--------------------------------------------------------------------------------
/03-21-functions-and-scope/solution-code/dice/css/style.css:
--------------------------------------------------------------------------------
1 | /*
2 | Project Name: Blank Template
3 | Client: Your Client
4 | Author: Your Name
5 | Developer @GA in NYC
6 | */
7 |
8 |
9 | /******************************************
10 | /* SETUP
11 | /*******************************************/
12 |
13 | /* Box Model Hack */
14 | * {
15 | -moz-box-sizing: border-box; /* Firexfox */
16 | -webkit-box-sizing: border-box; /* Safari/Chrome/iOS/Android */
17 | box-sizing: border-box; /* IE */
18 | }
19 |
20 | /* Clear fix hack */
21 | .clearfix:after {
22 | content: ".";
23 | display: block;
24 | clear: both;
25 | visibility: hidden;
26 | line-height: 0;
27 | height: 0;
28 | }
29 |
30 | .clear {
31 | clear: both;
32 | }
33 |
34 | .alignright {
35 | float: right;
36 | padding: 0 0 10px 10px; /* note the padding around a right floated image */
37 | }
38 |
39 | .alignleft {
40 | float: left;
41 | padding: 0 10px 10px 0; /* note the padding around a left floated image */
42 | }
43 |
44 | /******************************************
45 | /* BASE STYLES
46 | /*******************************************/
47 |
48 | body {
49 | color: #000;
50 | font-size: 12px;
51 | line-height: 1.4;
52 | font-family: Helvetica, Arial, sans-serif;
53 | }
54 |
55 |
56 | /******************************************
57 | /* LAYOUT
58 | /*******************************************/
59 |
60 | /* Center the container */
61 | #container {
62 | width: 960px;
63 | margin: auto;
64 | }
65 |
66 | #content span {
67 | width: 100px;
68 | height: 100px;
69 | display: inline-block;
70 | margin: 20px;
71 | background-repeat: no-repeat;
72 | background-position: top left;
73 | }
74 |
75 | .dice-1 {
76 | background-image: url('../img/1.png');
77 | }
78 | .dice-2 {
79 | background-image: url('../img/2.png');
80 | }
81 | .dice-3 {
82 | background-image: url('../img/3.png');
83 | }
84 | .dice-4 {
85 | background-image: url('../img/4.png');
86 | }
87 | .dice-5 {
88 | background-image: url('../img/5.png');
89 | }
90 | .dice-6 {
91 | background-image: url('../img/6.png');
92 | }
93 | /******************************************
94 | /* ADDITIONAL STYLES
95 | /*******************************************/
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/03-21-functions-and-scope/starter-code/dice/css/style.css:
--------------------------------------------------------------------------------
1 | /*
2 | Project Name: Blank Template
3 | Client: Your Client
4 | Author: Your Name
5 | Developer @GA in NYC
6 | */
7 |
8 |
9 | /******************************************
10 | /* SETUP
11 | /*******************************************/
12 |
13 | /* Box Model Hack */
14 | * {
15 | -moz-box-sizing: border-box; /* Firexfox */
16 | -webkit-box-sizing: border-box; /* Safari/Chrome/iOS/Android */
17 | box-sizing: border-box; /* IE */
18 | }
19 |
20 | /* Clear fix hack */
21 | .clearfix:after {
22 | content: ".";
23 | display: block;
24 | clear: both;
25 | visibility: hidden;
26 | line-height: 0;
27 | height: 0;
28 | }
29 |
30 | .clear {
31 | clear: both;
32 | }
33 |
34 | .alignright {
35 | float: right;
36 | padding: 0 0 10px 10px; /* note the padding around a right floated image */
37 | }
38 |
39 | .alignleft {
40 | float: left;
41 | padding: 0 10px 10px 0; /* note the padding around a left floated image */
42 | }
43 |
44 | /******************************************
45 | /* BASE STYLES
46 | /*******************************************/
47 |
48 | body {
49 | color: #000;
50 | font-size: 12px;
51 | line-height: 1.4;
52 | font-family: Helvetica, Arial, sans-serif;
53 | }
54 |
55 |
56 | /******************************************
57 | /* LAYOUT
58 | /*******************************************/
59 |
60 | /* Center the container */
61 | #container {
62 | width: 960px;
63 | margin: auto;
64 | }
65 |
66 | #content span {
67 | width: 100px;
68 | height: 100px;
69 | display: inline-block;
70 | margin: 20px;
71 | background-repeat: no-repeat;
72 | background-position: top left;
73 | }
74 |
75 | .dice-1 {
76 | background-image: url('../img/1.png');
77 | }
78 | .dice-2 {
79 | background-image: url('../img/2.png');
80 | }
81 | .dice-3 {
82 | background-image: url('../img/3.png');
83 | }
84 | .dice-4 {
85 | background-image: url('../img/4.png');
86 | }
87 | .dice-5 {
88 | background-image: url('../img/5.png');
89 | }
90 | .dice-6 {
91 | background-image: url('../img/6.png');
92 | }
93 | /******************************************
94 | /* ADDITIONAL STYLES
95 | /*******************************************/
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/03-21-functions-and-scope/starter-code/currency-converter/css/style.css:
--------------------------------------------------------------------------------
1 | /*
2 | Project Name: Blank Template
3 | Client: Your Client
4 | Author: Your Name
5 | Developer @GA in NYC
6 | */
7 |
8 |
9 | /******************************************
10 | /* SETUP
11 | /*******************************************/
12 |
13 | /* Box Model Hack */
14 | * {
15 | -moz-box-sizing: border-box; /* Firexfox */
16 | -webkit-box-sizing: border-box; /* Safari/Chrome/iOS/Android */
17 | box-sizing: border-box; /* IE */
18 | }
19 |
20 | /* Clear fix hack */
21 | .clearfix:after {
22 | content: ".";
23 | display: block;
24 | clear: both;
25 | visibility: hidden;
26 | line-height: 0;
27 | height: 0;
28 | }
29 |
30 | .clear {
31 | clear: both;
32 | }
33 |
34 | .alignright {
35 | float: right;
36 | padding: 0 0 10px 10px; /* note the padding around a right floated image */
37 | }
38 |
39 | .alignleft {
40 | float: left;
41 | padding: 0 10px 10px 0; /* note the padding around a left floated image */
42 | }
43 |
44 | /******************************************
45 | /* BASE STYLES
46 | /*******************************************/
47 |
48 | body {
49 | color: #000;
50 | font-size: 12px;
51 | line-height: 1.4;
52 | font-family: Helvetica, Arial, sans-serif;
53 | }
54 |
55 |
56 | /******************************************
57 | /* LAYOUT
58 | /*******************************************/
59 |
60 | /* Center the container */
61 | #container {
62 | width: 960px;
63 | margin: auto;
64 | }
65 |
66 | #content span {
67 | width: 100px;
68 | height: 100px;
69 | display: inline-block;
70 | margin: 20px;
71 | background-repeat: no-repeat;
72 | background-position: top left;
73 | }
74 |
75 | .dice-1 {
76 | background-image: url('../img/1.png');
77 | }
78 | .dice-2 {
79 | background-image: url('../img/2.png');
80 | }
81 | .dice-3 {
82 | background-image: url('../img/3.png');
83 | }
84 | .dice-4 {
85 | background-image: url('../img/4.png');
86 | }
87 | .dice-5 {
88 | background-image: url('../img/5.png');
89 | }
90 | .dice-6 {
91 | background-image: url('../img/6.png');
92 | }
93 | /******************************************
94 | /* ADDITIONAL STYLES
95 | /*******************************************/
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/03-21-functions-and-scope/solution-code/currency-converter/css/style.css:
--------------------------------------------------------------------------------
1 | /*
2 | Project Name: Blank Template
3 | Client: Your Client
4 | Author: Your Name
5 | Developer @GA in NYC
6 | */
7 |
8 |
9 | /******************************************
10 | /* SETUP
11 | /*******************************************/
12 |
13 | /* Box Model Hack */
14 | * {
15 | -moz-box-sizing: border-box; /* Firexfox */
16 | -webkit-box-sizing: border-box; /* Safari/Chrome/iOS/Android */
17 | box-sizing: border-box; /* IE */
18 | }
19 |
20 | /* Clear fix hack */
21 | .clearfix:after {
22 | content: ".";
23 | display: block;
24 | clear: both;
25 | visibility: hidden;
26 | line-height: 0;
27 | height: 0;
28 | }
29 |
30 | .clear {
31 | clear: both;
32 | }
33 |
34 | .alignright {
35 | float: right;
36 | padding: 0 0 10px 10px; /* note the padding around a right floated image */
37 | }
38 |
39 | .alignleft {
40 | float: left;
41 | padding: 0 10px 10px 0; /* note the padding around a left floated image */
42 | }
43 |
44 | /******************************************
45 | /* BASE STYLES
46 | /*******************************************/
47 |
48 | body {
49 | color: #000;
50 | font-size: 12px;
51 | line-height: 1.4;
52 | font-family: Helvetica, Arial, sans-serif;
53 | }
54 |
55 |
56 | /******************************************
57 | /* LAYOUT
58 | /*******************************************/
59 |
60 | /* Center the container */
61 | #container {
62 | width: 960px;
63 | margin: auto;
64 | }
65 |
66 | #content span {
67 | width: 100px;
68 | height: 100px;
69 | display: inline-block;
70 | margin: 20px;
71 | background-repeat: no-repeat;
72 | background-position: top left;
73 | }
74 |
75 | .dice-1 {
76 | background-image: url('../img/1.png');
77 | }
78 | .dice-2 {
79 | background-image: url('../img/2.png');
80 | }
81 | .dice-3 {
82 | background-image: url('../img/3.png');
83 | }
84 | .dice-4 {
85 | background-image: url('../img/4.png');
86 | }
87 | .dice-5 {
88 | background-image: url('../img/5.png');
89 | }
90 | .dice-6 {
91 | background-image: url('../img/6.png');
92 | }
93 | /******************************************
94 | /* ADDITIONAL STYLES
95 | /*******************************************/
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/03-14-data-types/lab-solution.md:
--------------------------------------------------------------------------------
1 | ## Data Collections
2 |
3 | ### Arrays
4 |
5 | Javascript provides us with a number of native methods that allow us to interact with arrays. Find methods that do each of the following and provide an example...
6 |
7 |
8 | ```js
9 | var nums = [1,2,3]
10 | // * Add an element to the back of an array.
11 | nums.push(4)
12 | // * Remove an element from the back of an array.
13 | nums.pop()
14 | // * Add an element to the front of an array.
15 | nums.unshift(0)
16 | // * Remove an element from the front of an array.
17 | nums.shift()
18 | // * Concatenates all the elements in an array into a string.
19 | nums.join('')
20 | // * Separates the characters of a string into an array.
21 | var str = "supercalifragilisticexpialidocious"
22 | str.split("")
23 | ```
24 |
25 | What will the contents of the below arrays be after the code samples are executed? Come up with an answer yourself before testing it out in the console.
26 | > **HINT:** You might find it helpful to draw the arrays out as you run each line of code.
27 |
28 | ```js
29 | var numbers = [ 2, 4, 6, 8 ];
30 |
31 | ```
32 |
33 | ```js
34 | numbers.pop(); // [2,4,6]
35 | numbers.push( 10 ); // [2,4,6,10]
36 | numbers.unshift( 3 ); // [3,2,4,6,10]
37 | ```
38 |
39 | What is the return value of the below code sample? Come up with an answer yourself before testing it out in the console.
40 |
41 | ```js
42 | var morse = [ "dot", "pause", "dot" ];
43 | var moreMorse = morse.join( " dash " ); // "dot dash pause dash dot"
44 | moreMorse.split( " " ); // ["dot","dash","pause","dot"]
45 | ```
46 |
47 | What will the contents of the below array be after the below code sample is executed? Come up with an answer yourself before testing it out in the console.
48 |
49 | ```js
50 | var bands = [];
51 | var beatles = [ "Paul", "John", "George", "Pete" ];
52 | var stones = [ "Brian", "Mick", "Keith", "Ronnie", "Charlie" ];
53 | bands.push( beatles ); // [["Paul", "John", "George", "Pete"]]
54 | bands.unshift( stones );// [[ "Brian", "Mick", "Keith", "Ronnie", "Charlie" ],["Paul", "John", "George", "Pete"]]
55 | bands[ bands.length - 1 ].pop(); // [[ "Brian", "Mick", "Keith", "Ronnie", "Charlie" ],["Paul", "John", "George"]]
56 | bands[0].shift(); // [["Mick", "Keith", "Ronnie", "Charlie" ],["Paul", "John", "George"]]
57 | bands[1][3] = "Ringo"; // [["Mick", "Keith", "Ronnie", "Charlie" ],["Paul", "John", "George","Ringo"]]
58 | ```
59 |
--------------------------------------------------------------------------------
/04-11-ajax-and-apis/solution-code/03-posts_requests/main.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var FavoriteThings = {
4 | elements: {
5 | $thingList: $('#todo-list'),
6 | $button: $('#new-thing-button'),
7 | $form: $('#new-thing-form'),
8 | $newItemInput: $('#new-thing'),
9 | $toDoTemplate: $("#to-do-template")
10 | },
11 | add: function(thing){
12 | var $listItem = FavoriteThings.render(FavoriteThings.elements.$toDoTemplate,thing);
13 | FavoriteThings.elements.$thingList.append($listItem);
14 | FavoriteThings.elements.$newItemInput.val('');
15 | // send a post request to "/things"
16 | // data: { newThing: thing.text }
17 | $.ajax({
18 | url: "/things",
19 | method: "post",
20 | data: {
21 | newThing: thing.text
22 | }
23 | })
24 | },
25 | markComplete: function(event){
26 | event.preventDefault();
27 | $(this).parent().addClass("completed");
28 | var thing = $(this).siblings(".todo-text").html()
29 | // send a patch request to /things/thing-text
30 | // e.g. /things/my+favorite+thing
31 | $.ajax({
32 | url: "/things/" + thing,
33 | method: "patch",
34 | data: {
35 | completed: true
36 | }
37 | })
38 | },
39 | delete: function(event){
40 | event.preventDefault();
41 | $(this).parent().remove();
42 | // send a delete request to /thing
43 | // data: { thing: thing.text }
44 | // modify server.js to delete the thing
45 | },
46 | listen: function(){
47 | FavoriteThings.elements.$form.on("submit", function(event){
48 | event.preventDefault();
49 | FavoriteThings.add({
50 | text: FavoriteThings.elements.$newItemInput.val(),
51 | completed: false
52 | })
53 | })
54 | FavoriteThings.elements.$thingList.on(
55 | "click", 'a.complete',
56 | FavoriteThings.markComplete
57 | )
58 | FavoriteThings.elements.$thingList.on(
59 | "click", 'a.delete',
60 | FavoriteThings.delete
61 | )
62 | },
63 | render: function($element, context){
64 | var source = $element.html();
65 | var template = Handlebars.compile(source);
66 | var html = template(context);
67 | return $(html);
68 | },
69 | load: function(callback){
70 | $.get("/things", function(response){
71 | console.log(response)
72 | response.forEach(function(thing){
73 | FavoriteThings.elements.$thingList.append(
74 | FavoriteThings.render(FavoriteThings.elements.$toDoTemplate,thing)
75 | )
76 | })
77 | callback(response)
78 | })
79 | }
80 | };
81 |
82 | FavoriteThings.load(function(){
83 | FavoriteThings.listen()
84 | })
85 |
--------------------------------------------------------------------------------
/05-04-CRUD/solution-code/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | The Bey Hive
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
33 |
34 |
35 |
36 |
37 |
44 |
45 |
46 |
47 |
48 |
Post a message for all fans of Beyonce AND Beyonce to see!