Create a component definition, which will be loaded in both the parent and child windows.
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
// 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
// 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
// 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
// Create a 'sayTo' function that lets you "say something to someone" like so: | |
let sayToJill = sayTo('Jill'); | |
sayToJill.say('hello'); // logs 'hello Jill!' | |
sayToJill.say('goodbye'); // logs 'goodbye Jill!' |
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 'once' function that generates a new function which can only be called once | |
function sayHello() { | |
console.log('hello'); | |
} | |
var sayHelloOnce = once(sayHello); | |
sayHelloOnce(); // logs 'hello' | |
sayHelloOnce(); // does nothing |
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
async function makePizza(sauceType = 'red') { | |
let dough = makeDough(); | |
let sauce = makeSauce(sauceType); | |
let cheese = grateCheese((await sauce).determineCheese()); | |
(await dough).add(await sauce); | |
(await dough).add(await cheese); | |
return await dough; |
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
var serialAsyncMap = function () { | |
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(collection, fn) { | |
var result, _iterator, _isArray, _i, _ref2, item; | |
return regeneratorRuntime.wrap(function _callee$(_context) { | |
while (1) { | |
switch (_context.prev = _context.next) { | |
case 0: | |
result = []; | |
_iterator = collection, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator](); |
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
<script src="https://www.paypalobjects.com/api/checkout.js"></script> | |
<div class="container"> | |
<p>Choose your method of payment: </p> | |
<form> | |
<div class="radio resize"> | |
<label> | |
<input type="radio" name="paymentOption" value="paypal" checked> | |
<img src="../img/payWithPaypal.jpg" alt="Pay with Paypal" class="paymentOptions" width="55" height="40"> | |
</label> |