This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Register a pair of ES6 classes called "Animal" and "Cat" with inheritance, so I can do: | |
| var animal = new Animal(); | |
| animal.walk(); // logs 'The Animal walked' | |
| var cat = new Cat(); | |
| cat.walk(); // logs 'The Cat walked' | |
| cat.meow(); // logs 'The Cat meowed' | |
| console.log(cat instanceof Cat); // logs true | |
| console.log(cat instanceof Animal); // logs true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Register a pair of ES6 classes called "Animal" and "Cat" *without* inheritance, so I can do: | |
| var animal = new Animal(); | |
| animal.walk(); // logs 'The Animal walked' | |
| var cat = new Cat(); | |
| cat.walk(); // logs 'The Cat walked' | |
| cat.meow(); // logs 'The Cat meowed' | |
| console.log(cat instanceof Cat); // logs true | |
| console.log(cat instanceof Animal); // logs false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Here's a mock ajax function | |
| function ajax(url, callback) { | |
| setTimeout(function() { | |
| if (Math.random() < 0.25) { | |
| callback(new Error(`Something went wrong calling ${url}`)) | |
| } else { | |
| callback(null, { | |
| url: url, | |
| data: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Implement async.parallel | |
| // It should take: 1. An array of asynchronous functions, 2. A final callback | |
| // It should run all of the functions in parallel (just like in the ajax exercise) | |
| // When all the calls are complete, it should call finalCallback with an array of the results from each call | |
| // If there is any error, it should call finalCallback with the first error that comes from any of the functions | |
| // It should only call finalCallback *one* time, either with an error, or with an array of results | |
| async.parallel = function(functions, finalCallback) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Create a form with: | |
| // * A text field for a credit card number | |
| // * A button to submit the credit card | |
| // | |
| // Requirements: | |
| // | |
| // - The page should do some client side validation, and only allow credit card numbers which are: | |
| // * 16 digits long |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 1. Create a web form with a text box and a button. When the button is pressed, it should output a base64 encoded version of the text onto the page | |
| // 2. Implement Array::map() | |
| // 3. Implement Array::forEach() | |
| // 4. Create a web form with a text field and a button. I should be able to enter a new word, press the button, and it should add my word to the page and keep all of the words that have been added in alphabetical order. | |
| // 5. Create a 3x3 grid on the page and let me click on each grid element. This should toggle each square between black and white. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getPerson(name) { | |
| let result = ajax('/api/person/' + name); | |
| return result.person; | |
| } | |
| function getPersonDateOfBirth(name) { | |
| let person = getPerson(name); | |
| return person.dob; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 1. Write a `until(condition, finalCallback)` function that calls the `condition` function until the result is truthy, then calls the final callback | |
| function waitUntilUserLoggedIn() { | |
| until(function(callback) { | |
| ajax('/api/user', function(err, user) { | |
| if (err) { | |
| callback(err); | |
| } else { | |
| callback(null, user.is_logged_in ? true : false) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const request = require('request-promise'); | |
| const ENV = 'sandbox'; | |
| const CLIENT_ID = 'AZDxjDScFpQtjWTOUtWKbyN_bDt4OgqaF4eYXlewfBP4-8aqX3PiV8e1GWU6liB2CUXlkA59kJXE7M6R'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <head> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
| <script src="https://www.paypalobjects.com/api/checkout.js"></script> | |
| <script src="http://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/ScrollMagic.min.js"></script> | |
| </head> | |
| <body> | |
| <div id="container"> |