├── .DS_Store ├── Week-1 ├── .DS_Store └── WeekOneSolution.js ├── Week-2 ├── .DS_Store ├── ExerciseOne │ ├── .DS_Store │ ├── index.html │ └── facebookSignUp.js ├── ExerciseTwo │ ├── .DS_Store │ ├── index.html │ ├── collectingRelationships.js │ └── collectionRelationships.md └── ExerciseThree │ ├── index.html │ ├── theBookStore.md │ └── bookStoreApp.js ├── README.md └── LICENSE /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albreyb/Telegraph-Prep-Curriculum/HEAD/.DS_Store -------------------------------------------------------------------------------- /Week-1/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albreyb/Telegraph-Prep-Curriculum/HEAD/Week-1/.DS_Store -------------------------------------------------------------------------------- /Week-2/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albreyb/Telegraph-Prep-Curriculum/HEAD/Week-2/.DS_Store -------------------------------------------------------------------------------- /Week-2/ExerciseOne/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albreyb/Telegraph-Prep-Curriculum/HEAD/Week-2/ExerciseOne/.DS_Store -------------------------------------------------------------------------------- /Week-2/ExerciseTwo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albreyb/Telegraph-Prep-Curriculum/HEAD/Week-2/ExerciseTwo/.DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Telegraph-Prep-Curriculum 2 | Curriculum for Telegraph Prep. Learn JavaScript in 4 short weeks! 3 | ![Alt text](https://lh3.googleusercontent.com/proxy/0h8c3IWfGOoHxfp6MVPD679o2b7RLJPa25cm2MxRr9IcimKO2fa9CZ8jZ7AVqJT0DX-mtyVdFCig-ZsPRIhHvM5yxIBV7uyv5Nlun6pKSUeoJ35Zn5qYwC9h-A=s426 "Telegraph Prep!") 4 | -------------------------------------------------------------------------------- /Week-2/ExerciseOne/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Telegraph Prep Week 2 6 | 7 | 8 | 9 |
10 | 11 |

This Page is intentionally left blank. Please open the javascript console in your developer tools

12 |

13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Week-2/ExerciseThree/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Telegraph Prep Week 2 6 | 7 | 8 | 9 |
10 | 11 |

This Page is intentionally left blank. Please open the javascript console in your developer tools

12 |

13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Week-2/ExerciseTwo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Telegraph Prep Week 2 6 | 7 | 8 | 9 |
10 | 11 |

This Page is intentionally left blank. Please open the javascript console in your developer tools

12 |

13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Albrey Bristo-Brown 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 | -------------------------------------------------------------------------------- /Week-2/ExerciseTwo/collectingRelationships.js: -------------------------------------------------------------------------------- 1 | var youDontNeedToWorryAboutAnythingInHere = function() { 2 | var NameArray = ['Noel Plain', 'Steffanie Plain', 'Hester Sanderfur', 'Retta Plain', 'Idella Saur','Shila Plain', "Marybeth Peavler", "Chadwick Jin", "Jerold Chauez", "Roselle Plain", "Doria Figgins", "Seth Arvizu", 'Gloria Wyche', "Melodi Plain", "Robin Shackleford", "Jack Plain", "Marina Prost", "Melvina Plain", "Ryan Plemons", "Janis Ohare", "Assata Shakur", "Kanye West", "Jay-Z", "Mariah Carey", "Bianca Gandolfo", "Cedric the Entertainer", "Chloe Plain"]; 3 | var JobArray = ['Mortician', 'Broadcaster', 'Craftsperson', 'Engineer', 'Interior designer', 'Nun']; 4 | var CityArray = ["Scottsdale, Arizona", "Oakland, California", "Stockton, California", "New York, NY"]; 5 | var emptyNetwork = []; 6 | 7 | function createNetwork(collection){ 8 | 9 | for (var i = 0; i < NameArray.length; i++) { 10 | var randomJob = JobArray[Math.floor(Math.random() * JobArray.length)]; 11 | var randomCity = CityArray[Math.floor(Math.random() * CityArray.length)]; 12 | 13 | collection.push(createNewUser(NameArray[i], randomJob, randomCity)); 14 | } 15 | 16 | return collection 17 | } 18 | 19 | return createNetwork(emptyNetwork); 20 | 21 | } 22 | 23 | function createNewUser(username, job, city){ 24 | var newUser = { 25 | username: username, 26 | job: job, 27 | city: city, 28 | friends: [], 29 | family: [], 30 | coworkers: [], 31 | }; 32 | 33 | return newUser; 34 | 35 | }; 36 | // creating the user you're going to be adding to 37 | var joeyProfile = createNewUser('Joey Plain', 'Engineer', 'Oakland, California'); 38 | // creating the network collection you're going to be pulling 39 | var allUsers = youDontNeedToWorryAboutAnythingInHere(); 40 | // check the console to see what these look like 41 | 42 | 43 | //console.dir(ourUser); 44 | //console.dir(userNetwork); 45 | 46 | 47 | 48 | // YOUR CODE HERE 49 | 50 | -------------------------------------------------------------------------------- /Week-1/WeekOneSolution.js: -------------------------------------------------------------------------------- 1 | //Use this file to implement Part One of your project 2 | var animal = {}; 3 | animal.username = "Bugs Bunny"; 4 | //console.log(animal.username); 5 | animal['tagline'] = "What's up Doc?" 6 | // console.log(animal.tagline); 7 | var noises = []; 8 | animal['noises'] = noises; 9 | //console.log(animal); 10 | var count = 0; 11 | for (var key in animal) { 12 | count++ 13 | if(key === 'username'){ 14 | console.log("Hi, my name is " + animal[key]); 15 | } else if (key === 'tagline') { 16 | console.log("I like to say, " + animal[key]); 17 | } 18 | } 19 | //console.log(count); 20 | var noiseArray = ['quack!']; 21 | noiseArray.push('flap!'); 22 | noiseArray.unshift('chirp!'); 23 | noiseArray[noiseArray.length] = 'hello!'; 24 | 25 | //console.log(noiseArray.length); 26 | //console.log(noiseArray); 27 | //console.log(noiseArray[noiseArray.length - 1]); 28 | animal.noises = noiseArray; 29 | 30 | var animals = []; 31 | animals.push(animal); 32 | var quackers = { 33 | username: 'DaffyDuck', 34 | tagline: 'Yippeee!', 35 | noises: ['quack', 'honk', 'sneeze', 'growl'] 36 | } 37 | 38 | animals[animals.length] = quackers; 39 | //console.log(animals); 40 | var bear = { 41 | username: "Winnie The Pooh", 42 | tagline: "Ooh! Honey!", 43 | noises: ['munch', 'oooh!', 'sigh'] 44 | 45 | }; 46 | 47 | var spiritAnimal = { 48 | username: "Usher", 49 | tagline: "Peace up, A Town Down", 50 | noises: ['u got it bad!', 'ow!', 'usha', 'yeah, yeah yeah!'] 51 | 52 | }; 53 | 54 | animals.push(bear, spiritAnimal); 55 | //console.log(animals.length); 56 | 57 | var friends = []; 58 | friends[0] = animals[0].username; 59 | friends[1] = animals[1].username; 60 | // console.log(friends); 61 | 62 | var relationships = {}; 63 | relationships.friends = friends; 64 | //console.log(realationships); 65 | 66 | var matches = []; 67 | relationships.matches = matches; 68 | relationships.matches[0] = animals[2].username; 69 | // console.log(relationships) 70 | 71 | for (var i = 0; i < animals.length; i++) { 72 | animals[i].relationships = relationships; 73 | } 74 | 75 | console.log(animals[0].relationships); 76 | 77 | var AnimalTestUser = function(username){ 78 | return { 79 | username: username 80 | } 81 | } 82 | 83 | var testSheep = AnimalTestUser('CottonBall'); 84 | // console.log(testSheep); 85 | 86 | var AnimalTestUserTwo = function(username) { 87 | var ourUser = {}; 88 | ourUser.username = username; 89 | if (arguments.length > 1) { 90 | // var otherArgs = Array.prototype.slice.call(arguments, 1); 91 | var otherArgs = []; 92 | for (var i = 1; i < arguments.length; i++) { 93 | otherArgs[i - 1] = arguments[i]; 94 | 95 | } 96 | ourUser.otherArgs = otherArgs; 97 | } 98 | 99 | return ourUser; 100 | } 101 | 102 | 103 | var testSheep2 = AnimalTestUserTwo("CottonBall", "yassss", 'kanye west'); 104 | 105 | //console.log(testSheep2); 106 | 107 | var AnimalCreator = function(username, species, tagline, noises) { 108 | return { 109 | username: username, 110 | species: species, 111 | tagline: tagline, 112 | noises: noises, 113 | friends: [], 114 | } 115 | }; 116 | 117 | var sheep = AnimalCreator('Cloud', 'sheep', 'You can count on me!', ['baahhh', 'arrgg', 'chewchewchew']); 118 | // console.log(sheep); 119 | 120 | var addFriend = function(animalOne, animalTwo) { 121 | animalOne.friends.push(animalTwo.username); 122 | //console.log("Your new friend " + animalOne.friends[animalOne.friends.length - 1]); 123 | }; 124 | 125 | var cow = AnimalCreator("E-Moo", "cow", "I'm utterly disgusted", ['moo', 'nomnomnom', 'yooooo!']) 126 | // console.log(cow); 127 | 128 | addFriend(sheep, cow); 129 | addFriend(sheep, bear); 130 | addFriend(sheep, spiritAnimal); 131 | addFriend(sheep, quackers); 132 | 133 | 134 | var frog = AnimalCreator("Jumper", "frog", "Jiggity jiggity jump to me, son!", ['ribbit', 'croak', 'snap!']) 135 | var myFarm = [cow, sheep, frog]; 136 | 137 | 138 | addFriend(frog) 139 | 140 | function giveMatches(farmArray) { 141 | for (var i = 0; i < farmArray.length; i++) { 142 | farmArray[i].matches = farmArray[i].friends[0] 143 | console.log(farmArray[i]); 144 | } 145 | } 146 | 147 | giveMatches(myFarm); 148 | -------------------------------------------------------------------------------- /Week-2/ExerciseThree/theBookStore.md: -------------------------------------------------------------------------------- 1 | #Bookstore Application! 2 | 3 | You've been called up as CTO of the hottest new app on the market, The Book Store. TBS's mission is to be the most comprehensive BookStore on the planet - but it needs some extra functionality to get it started. Over the next hours, you will build that functionality and make this application run. 4 | 5 | This lesson will test your knowledge of building functions and methods. In your scripts.js there are two functions that create your fully-loaded book store and a testUser. 6 | 7 | The testUser should have a balance and a cart. The balance represents how much money the test user has to spend on books. The cart holds the books that the user is interested in buying. 8 | 9 | Susan, our test user, is a college grad looking for some good reads. Let's first make sure she can quickly and efficiently look up things in our bookStore. 10 | 11 | 1. Create a function, checkStore, that takes a string as a parameter. 12 | 13 | (i) checkStore goes through our bookStore and checks each book title. 14 | 15 | (ii) If the title matches the input string, we ask the user whether he or she wants to add it to their cart. 16 | ``` 17 | Your prompt should look like this: 18 | We found your book! [Title of Book], by [Name of Author]. It costs [price]. 19 | 20 | Would you like to add it to your cart? 21 | ``` 22 | 23 | (iii) If the title isn't found, alert the user that it wasn't found. 24 | 25 | 2. Create a method, deleteBook, and put it on your testUser object. 26 | 27 | (i) deleteBook takes a string parameter, and checks it against the books in the user's cart. 28 | 29 | (ii) If the book is in the cart, ask the user if they're sure they want to delete it using confirm(). 30 | 31 | (iii) If they do want to delete, take the book out of the cart. 32 | 33 | (iv) Inspect the cart to make sure the book was deleted. 34 | 35 | 3. Create a method, clearCart, and put it on your testUser object. 36 | 37 | (i) clearCart prompts the user as to whether they're SURE they want to clear their cart. 38 | 39 | (ii) If they confirm yes, delete everything in their cart. 40 | 41 | (iii) Inspect the cart to make sure it's empty. 42 | 43 | 4. Create a method, checkOut, and put it on your testUser object. 44 | 45 | (i) checkOut adds up the total price of the books in the user's cart and compares it to their balance. 46 | 47 | (ii) If their balance is higher than the the total of the combined books, let them check out. 48 | 49 | ``` 50 | checkout() ---> 'YOUVE SUCCESSFULLY CHECKED OUT!' 51 | 52 | ``` 53 | 54 | (iii) If their balance is lower than the total of the combined books, tell them to get their money up and try again later (jk be nice about it). 55 | 56 | YOU ARE NOW ENTERING HARD MODE 57 | 5. Let's open up our functionality a bit so Susan can more easily find books. 58 | 59 | (i) Instead of just checking for the title, let's let our testUser look up books by author and type of book as well. 60 | 61 | (ii) If there are multiple titles by the same author, or multiple books of the same type, send the user a prompt that lists the books like so: 62 | ``` 63 | checkStore('classic') 64 | --> There are multiple books that are classics, which one would you like? 65 | When Things Fall Apart by Chenua Achebe 66 | Moby Dick by Herman Melville 67 | I Know Why The Cagebird Sings by Maya Angelou 68 | ``` 69 | 70 | (iii) After the user enters the book title they want, add it to their cart. 71 | 72 | (iv) Inspect the cart to make sure the right book was inserted. 73 | 74 | 6. Susan is balling on a budget! Let's allow our user to delete multiple books by their price. 75 | 76 | (i) If the user passes a number as an argument to our deleteBook function, return all the books 77 | that are equal to and larger than that price point. 78 | 79 | (ii) Much like on #5, let the user know which books fit their parameters. 80 | ``` 81 | deleteBook(20) ---> 82 | These are the books equal to and above 20$: 83 | 84 | A Clock Work Orange by Anthony Burgess (27$) 85 | Enders Game by Orson Scott Card (35$) 86 | 87 | Which one would you like to take out of your cart? 88 | ``` 89 | 90 | (iii) If the value of their input is equal to the book title, delete the book. 91 | 92 | - MORE COMPLEX FUNCTIONALITY: CREDIT CARD INFORMATION PROCESSINGo (ASK ALBREY ABOUT THIS). 93 | >>>>>>> 8f34a31a1e2c5e489f3c9c74b21d1bf724a3d50f 94 | 95 | 96 | -------------------------------------------------------------------------------- /Week-2/ExerciseTwo/collectionRelationships.md: -------------------------------------------------------------------------------- 1 | #Array Exercises Week 2 2 | 3 | ## User Network 4 | 5 | Our User, Joey Plain has just signed up for Facebook! He's very excited and wants to start building out his network as quickly as possible - and we're going to help him get started. 6 | 7 | Don't mess with lines 1 through 35. They are used to create Joey's user object (joeyProfile) and the network of all users on Facebook (allUsers). We're going to use allUsers to help him find his friends, family, and coworkers. 8 | 9 | 1. First, let's inspect joeyProfile and allUsers to see what we have. 10 | 11 | (i) console.dir the joeyProfile object. It should have a friends, family, and coworkers arrays. 12 | 13 | (ii) console.dir the allUsers collection. It should have > 20 objects with the same properties as your joeyProfile object. 14 | 15 | 16 | 2. Next, let's add some friends to the empty joeyProfile friends collection. 17 | 18 | (i) Loop through the allUsers array. On each iteration, we'll have a single user object. 19 | 20 | (ii) If a user in the allUsers array is from the same city as joeyProfile, push the username into the joeyProfile friends array. 21 | 22 | 23 | 3. Next, let's add some coworkers to the empty joeyProfile coworkers collection. 24 | 25 | (i) Loop through the allUsers array. 26 | 27 | (ii) If a user in the allUsers array has the same job as Joey, push the username into the joeyProfile coworker array. 28 | 29 | 30 | 4. Next, let's add some family members to the empty joeyProfile family collection. 31 | 32 | (i) Loop through the allUsers array. 33 | 34 | (ii) If a user in the allUsers array has the same last name, push the username into the joeyProfile family array. 35 | 36 | (iii) **You'll have to do something special to check JUST the last name. Check out the split() function.** 37 | 38 | 39 | 5. Now let's make sure there aren't any duplicate usernames in our friends and family arrays. If 'Doug Flutie' is in our family array, it shouldn't be in our friends array. If it is, let's delete it from our friends array, as family is more important to Joey. 40 | 41 | (i) Loop through our family array. 42 | 43 | (ii) Inside of our family loop, loop through our friends array. What this is diong? While we're on each family member, check that family member against every person in the friends array. 44 | 45 | (iii) If the current family member is equal to the current element of our friends array, delete the element from our friends array. 46 | 47 | (iv) There are a couple of ways to delete things from an array. Look up .splice() and try to use that. 48 | 49 | 50 | 6. Now let's make sure there aren't any duplicate usernames in our friends and coworkers arrays. If 'Doug Flutie' is in our friends array, it shouldn't be in our coworkers array. If it is, let's delete it from our coworkers array, as friends are more important to Joey. 51 | 52 | (i) Loop through our friends array. 53 | 54 | (ii) Inside of our friends loop, loop through our coworkers array. 55 | 56 | (iii) If the value of the current element inside of our coworkers array is equal to the current element of our friends array, delete the element in our coworkers array. 57 | 58 | 59 | YOU ARE NOW ENTERING NIGHTMARE MODE: 60 | 61 | 7. Now that we have all of our arrays filled, let's sort each array by alphabetical order. 62 | 63 | (i) Create a function called nameSort that takes an array and sorts its contents by alphabetical order. **hint: arrays may have a method that does this.** 64 | 65 | (ii) Use nameSort on each array in our joeyProfile object. 66 | 67 | (iii) Check each array by using console.dir to make sure its contents are sorted by the end. 68 | 69 | 70 | 8. Joey wants to be able to instantly look up whether someone is in one of his networks. 71 | 72 | (i) Create a function, networkCheck, that takes an array and a name. 73 | 74 | (ii) If the name exists in the array, alert the users full profile formatted exactly like the example below. 75 | 76 | ``` 77 | nameCheck(friendsArray, 'Solomon Daniels'); 78 | 79 | 'Name: Solomon Daniels 80 | Job: Engineer 81 | City: Berkeley, California 82 | Friends: 0, 83 | Family: 0, 84 | Coworkers: 0' 85 | 86 | ``` 87 | (iii) If the person doesn't exist, set up a prompt that asks for the friend's info (name, job, city) and adds it to an object named newUser. (newUser should have friends, family, and coworkers arrays inside of it as well- sound familiar?). 88 | 89 | (iv) Add newUser to the input array passed to nameCheck (friendsArray, in the example above on line 77) and call nameCheck on the array to make sure it exists. 90 | -------------------------------------------------------------------------------- /Week-2/ExerciseThree/bookStoreApp.js: -------------------------------------------------------------------------------- 1 | // In Javascript, the leading __ in a variable name signifies that this is a variable you probably shouldn't be messing with. 2 | // NOTE: the leading underscore IN the variable name is different than the underscorejs.org library, 3 | // which uses underscore as an object and INVOKES METHODS on that object, "_.each()" for example. 4 | function __dontWorryAboutThis(){ 5 | var __books = "Lucky Jim by Kingsley Amis, Money by Martin Amis, The Information by Martin Amis, The Bottle Factory Outing by Beryl Bainbridge, According to Queeney by Beryl Bainbridge, Flaubert's Parrot by Julian Barnes, A History of the World in 10 1/2 Chapters by Julian Barnes, Augustus Carp Esq. by Himself: Being the Autobiography of a Really Good Man by Henry Howarth Bashford, Molloy by Samuel Beckett, Zuleika Dobson by Max Beerbohm, The Adventures of Augie March by Saul Bellow, The Uncommon Reader by Alan Bennett, Queen Lucia by EF Benson, The Ascent of Rum Doodle by WE Bowman, A Good Man in Africa by William Boyd, The History Man by Malcolm Bradbury, No Bed for Bacon by Caryl Brahms and SJ Simon, Illywhacker by Peter Carey, A Season in Sinji by JL Carr, The Harpole Report by JL Carr, The Hearing Trumpet by Leonora Carrington, Mister Johnson by Joyce Cary, The Horse's Mouth by Joyce Cary, Don Quixote by Miguel de Cervantes, The Case of the Gilded Fly by Edmund Crispin, Just William by Richmal Crompton, The Provincial Lady by EM Delafield, Slouching Towards Kalamazoo by Peter De Vries, The Pickwick Papers by Charles Dickens, Martin Chuzzlewit by Charles Dickens, Jacques the Fatalist and his Master by Denis Diderot, A Fairy Tale of New York by JP Donleavy, The Commitments by Roddy Doyle, Ennui by Maria Edgeworth, Cheese by Willem Elsschot, Bridget Jones's Diary by Helen Fielding, Joseph Andrews by Henry Fielding, Tom Jones by Henry Fielding, Caprice by Ronald Firbank, Bouvard et Pécuchet by Gustave Flaubert, Towards the End of the Morning by Michael Frayn, The Polygots by William Gerhardie, Cold Comfort Farm by Stella Gibbons, Dead Souls by Nikolai Gogol, Oblomov by Ivan Goncharov, The Wind in the Willows by Kenneth Grahame, Brewster's Millions by Richard Greaves (George Barr McCutcheon), Squire Haggard's Journal by Michael Green, Our Man in Havana by Graham Greene, Travels with My Aunt by Graham Greene, Diary of a Nobody by George Grossmith, The Little World of Don Camillo by Giovanni Guareschi, The Curious Incident of the Dog in the Night-time by Mark Haddon, Catch-22 by Joseph Heller, Mr Blandings Builds His Dream House by Eric Hodgkins, High Fidelity by Nick Hornby, I Served the King of England by Bohumil Hrabal, The Lecturer's Tale by James Hynes, Mr Norris Changes Trains by Christopher Isherwood, The Mighty Walzer Howard by Jacobson, Pictures from an Institution by Randall Jarrell, Three Men in a Boat by Jerome K Jerome, Finnegans Wake by James Joyce, The Castle by Franz Kafka, Lake Wobegon Days by Garrison Keillor, Death and the Penguin by Andrey Kurkov, The Debt to Pleasure by John Lanchester, L'Histoire de Gil Blas de Santillane (Gil Blas) by Alain-René Lesage, Changing Places by David Lodge, Nice Work by David Lodge, The Towers of Trebizond by Rose Macaulay, England Their England by AG Macdonell, Whisky Galore by Compton Mackenzie, Memoirs of a Gnostic Dwarf by David Madsen, Cakes and Ale - Or the Skeleton in the Cupboard by W Somerset Maugham, Tales of the City by Armistead Maupin, Bright Lights Big City by Jay McInerney, Puckoon by Spike Milligan, The Restraint of Beasts by Magnus Mills, Charade by John Mortimer, Titmuss Regained by John Mortimer, Under the Net by Iris Murdoch, Pnin by Vladimir Nabokov, Pale Fire by Vladimir Nabokov, Fireflies by Shiva Naipaul, The Sacred Book of the Werewolf by Victor Pelevin, La Disparition by Georges Perec, Les Revenentes by Georges Perec, La Vie Mode d'Emploi by Georges Perec, My Search for Warren Harding by Robert Plunkett, A Dance to the Music of Time by Anthony Powell, A Time to be Born by Dawn Powell, Excellent Women by Barbara Pym, Less Than Angels by Barbara Pym, Zazie in the Metro by Raymond Queneau, Solomon Gursky Was Here by Mordecai Richler, Alms for Oblivion by Simon Raven, Portnoy's Complaint by Philip Roth, The Westminster Alice by Saki, The Unbearable Bassington by Saki , Hurrah for St Trinian's by Ronald Searle, Great Apes by Will Self, Porterhouse Blue by Tom Sharpe, Blott on the Landscape by Tom Sharpe, Office Politics by Wilfrid Sheed, Belles Lettres Papers: A Novel by Charles Simmons, Moo by Jane Smiley, Topper Takes a Trip by Thorne Smith, The Adventures of Ferdinand Count Fathom by Tobias Smollett, The Adventures of Roderick Random by Tobias Smollett, The Adventures of Peregrine Pickle by Tobias Smollett, The Expedition of Humphry Clinker by Tobias Smollett, The Prime of Miss Jean Brodie by Muriel Spark, The Girls of Slender Means by Muriel Spark, The Driver's Seat by Muriel Spark, Loitering with Intent by Muriel Spark, A Far Cry from Kensington by Muriel Spark, The Life and Opinions by Tristram Shandy, Gentleman by Laurence Sterne, White Man Falling by Mike Stocks, Handley Cross by RS Surtees, A Tale of a Tub by Jonathan Swift, Penrod by Booth Tarkington, The Luck of Barry Lyndon by William Makepeace Thackeray, Before Lunch by Angela Thirkell, Tropic of Ruislip by Leslie Thomas, A Confederacy of Dunces by John Kennedy Toole, Barchester Towers by Anthony Trollope, Venus on the Half-Shell by Kilgore Trout, The Mysterious Stranger by Mark Twain, The Witches of Eastwick by John Updike, Breakfast of Champions by Kurt Vonnegut, Infinite Jest by David Foster Wallace, Decline and Fall by Evelyn Waugh, Vile Bodies by Evelyn Waugh, Black Mischief by Evelyn Waugh, Scoop by Evelyn Waugh, The Loved One by Evelyn Waugh, A Handful of Dust by Evelyn Waugh , The Life and Loves of a She-Devil by Fay Weldon, Tono Bungay by HG Wells, Molesworth by Geoffrey Willans and Ronald Searle, The Wimbledon Poisoner by Nigel Williams, Anglo-Saxon Attitudes by Angus Wilson, Something Fresh by PG Wodehouse, Piccadilly Jim by PG Wodehouse, Thank You Jeeves by PG Wodehouse, Heavy Weather by PG Wodehouse, The Code of the Woosters by PG Wodehouse, Joy in the Morning by PG Wodehouse"; 6 | var __bookStore = []; 7 | var __booksArray = __books.split(','); 8 | var __categories = ['classic', 'horror', 'romantic comedy', 'self help', 'historical'] 9 | 10 | function __createBook(bookName){ 11 | var price = Math.random() * 20; 12 | price = parseFloat(price.toString().slice(0, 4), 10); 13 | var category = (__categories[Math.floor(Math.random() * 5)]) 14 | 15 | return { 16 | title: bookName.split('by')[0].trim(), 17 | author: bookName.split('by')[1].trim(), 18 | price: price, 19 | category: category 20 | } 21 | } 22 | 23 | function __createBookStore(arr) { 24 | for (var i = 0; i < arr.length; i++) { 25 | __bookStore.push(__createBook(arr[i])); 26 | } 27 | 28 | return __bookStore 29 | } 30 | 31 | return __createBookStore(__booksArray); 32 | 33 | } //Don't pay any attention to the man behind the curtain in lines 1-30. Remember, the leading underscores in the variable names mean you shouldn't be messing with these variables. 34 | 35 | function testUser(){ 36 | var balance = Math.random() * 100 + 130; 37 | balance = parseFloat(balance.toString().slice(0, 4), 10); 38 | return { 39 | balance: balance, 40 | cart: [], 41 | } 42 | } 43 | 44 | var BookStore = __dontWorryAboutThis(); 45 | var Susan = testUser(); 46 | 47 | console.log(Susan); -------------------------------------------------------------------------------- /Week-2/ExerciseOne/facebookSignUp.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Congratulations on making it to part two of Objects! This section 4 | is about using your new knowlege to debug a small program. 5 | 6 | Imagine you're a contracted developer brought on by Facebook to fix 7 | some of their internal bugs. The programmer before you 8 | made a lot of mistakes and its your job to use your new knowledge 9 | to clean up the mess. 10 | 11 | Even though they weren't a very good programmer, they 12 | were VERY thorough about leaving comments. Read the 13 | comments to get tips about the bugs as well as insights 14 | into new information about JavaScript. 15 | 16 | This section focuses on Objects and is working with pretty 17 | limited functionality. Throughout the course we'll fix bugs 18 | in more robust functionality so that you can see 19 | how your fundamentals will be used in the wild. 20 | 21 | *TIPS* 22 | 23 | 1. Each function depends on the one before it. 24 | Don't uncomment the next function until you've fixed the 25 | first one. 26 | 27 | 2. This is a bug treasure hunt. Its up to you to 28 | find and fix the bug in given parts of the program. Some 29 | mistakes are obvious, others are not -- attention to detail is key. 30 | 31 | 3. The console is your friend and will *usually* lead you in the 32 | right direction to the next bug. 33 | 34 | 4. If you don't recognize something look it up. The internet 35 | is your best friend - make sure you utilize it and expand 36 | your programming knowlege. 37 | 38 | 5. Have fun, if you're stuck for too long it becomes tedious. 39 | Don't feel bad for using the hints, these are tough exercises! 40 | 41 | */ 42 | 43 | // Here we make our facebookUser form which, in this case, 44 | // is an object. Each part of the form will be filled out 45 | // by the user using prompts. If you're unfamiliar with 46 | // prompts heres a good article: http://bit.ly/1CzM0Oe 47 | 48 | var facebookUser = { 49 | firstName: null, 50 | lastName: null, 51 | password: null, 52 | email: null, 53 | confirmPassword: null, 54 | }; 55 | 56 | /* 57 | 58 | The signUpNewMember function runs as soon the user gets to the site. 59 | It will ask the user questions and store answers in our 60 | facebookUser object so we can add it to the (fictional) database. 61 | 62 | There are a few bugs in our function. 63 | 64 | Follow the console, 1 bug will lead to the next. 65 | 66 | 67 | */ 68 | 69 | function signUpNewMember(){ 70 | 71 | /* 72 | 73 | first we've created a signUp function that gets the users 74 | information and stores it in our facebookUser object 75 | according to the corresponding key. First and foremost 76 | uncomment line 225 so we can invoke the function and start fixing 77 | it. 78 | 79 | */ 80 | 81 | function signUp(){ 82 | 83 | for (var key in facebookUser) { 84 | /* 85 | we need to check to see if the values assigned 86 | to our keys are null 87 | */ 88 | if (facebookUser.key === null) { 89 | 90 | /* 91 | if a value is null, ask the user to enter their 92 | information with a prompt on line 96 93 | */ 94 | 95 | //console.log(hintTwo()); 96 | var userInput = prompt("What's your " + facebookUser[key] + '?'); 97 | 98 | /* 99 | reassign the key value to the usersInput we just 100 | gathered from the user. 101 | */ 102 | 103 | key = userInput; 104 | //console.log(facebookUser) 105 | 106 | /* 107 | uncomment line 121 to see the reassignment working. 108 | Remember to comment it back when you move on to avoid 109 | cluttering the console. 110 | 111 | Your object should look something like this: 112 | facebookUser = { 113 | firstName: 'Earth', 114 | lastName: 'Wind, and Fire', 115 | password: 'bestOfAllTime', 116 | confirmPassword: 'bestOfAllTime', 117 | email: 'septemberIsAClassic@gmail.com' 118 | }; 119 | */ 120 | 121 | //console.log(hintThree()) 122 | 123 | } else { 124 | //console.log(hintOne()) 125 | } 126 | } 127 | 128 | // Working? Uncomment the checkAllFields function on line 226 and 129 | // get started on the next function 130 | 131 | } 132 | 133 | /* 134 | 135 | Next we need to make sure the user didn't forget to put 136 | any information in. If they have, we have to have them 137 | fill out that part of the form. 138 | 139 | */ 140 | 141 | function checkAllFields(){ 142 | facebookUser['favoriteFood'] = null; 143 | /* iterate through the facebookUser object*/ 144 | for (var key in facebookuser) { 145 | // check to see if the assigned value is null 146 | if (facebookUser.key === null) { 147 | 148 | /* 149 | if it is null, prompt the user to fill in the field 150 | they missed and save the answer as a value in your object. 151 | */ 152 | 153 | // console.log(hintFive()); 154 | key = prompt("You missed an input field " + "what's your " + facebookUser['key'] + '?'); 155 | 156 | } else { 157 | 158 | //console.log(hintFour()); 159 | } 160 | } 161 | 162 | // uncomment 165 to see if the field has been filled with 163 | // the value your user entered. 164 | 165 | //console.log(facebookUser); 166 | 167 | // If your finished, go ahead an uncomment line 227 and 168 | // move on to the last function, confirmInformation. 169 | } 170 | 171 | 172 | /* 173 | Next we need a function that confirms with the user 174 | that their information is correct. This way, they can 175 | double check before they make their profile. 176 | 177 | */ 178 | 179 | function confirmInformation(){ 180 | // userPrompt variable holds the explanation for the prompt 181 | var userPrompt = "Check to make sure the following information is correct. " + 182 | "If it is, type the word 'yes' into the textbox and press enter.\n" 183 | 184 | // iterate through the facebookUser object 185 | for (var key in facebookUser) { 186 | 187 | /* 188 | add our list of key's and values to the userPrompt string 189 | so they can see the full list of the information they 190 | entered. 191 | */ 192 | userPrmpt += (facebookUser[key].toUpperCase() + ': ' + facebookUser[key] + '\n'); 193 | console.log(hintSix()); 194 | } 195 | 196 | // save the users answer in a variable 197 | 198 | var userAnswer = prompt(userPrompt); 199 | 200 | /* 201 | check to see whether the users answer is yes, they've 202 | agreed that it's the right information. Let's go ahead 203 | and let them sign in. 204 | */ 205 | 206 | if (useranswer === 'yes') { 207 | /* 208 | if yes, alert the user that they are signed in by using 209 | */ 210 | 211 | // console.log(hintSeven()) 212 | 213 | var userFirstName = facebookUser.firstName; 214 | var userLastName = facebookUser.lastName; 215 | 216 | var signInPrompt = "Hello " + facebookUser.userFirstName + " " + facebookUser['userLastName'] + "you've been signed in!" 217 | 218 | alert(signinPrompt); 219 | //uncomment 220 once your functions all work 220 | //window.location.assign('http://media.tumblr.com/tumblr_m3ppveMgu71r4lux2.gif'); 221 | } 222 | 223 | } 224 | 225 | //signUp(); 226 | //checkAllFields(); 227 | //confirmInformation(); 228 | 229 | return facebookUser; 230 | } 231 | 232 | signUpNewMember(); 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | function hintOne(){ 265 | return "Put a console.log into your if statement (line 89) to see if it's running. If its not, what's wrong with our if statement?" 266 | } 267 | 268 | function hintTwo(){ 269 | return "Do we want our prompt printing null? If not, how can we make our prompt look like this 'What is your firstName?'" 270 | } 271 | 272 | function hintThree(){ 273 | return "Look at your object in the console, shouldn't the 'null' values be replaced with the users input?" 274 | } 275 | 276 | function hintFour(){ 277 | return "What's the difference between '=' and '==='"; 278 | } 279 | 280 | function hintFive(){ 281 | return "Is our prompt asking the user for the right information?" 282 | } 283 | 284 | function hintSix(){ 285 | return "Are your fields quite right? Double check and make sure everything makes sense!" 286 | } 287 | function hintSeven(){ 288 | return "Always strive to write more human-sounding code. How do we access a key using a variable?" 289 | } 290 | --------------------------------------------------------------------------------