Thunks 2
| javascriptWatched some more JS lectures by Kyle Simpson.
Assume that our task at hand is to request multiple files in parallel, but output them in a particular order. Given:
function frokneeAjax(url, cb) {
var sampleResponses = {
"file1": "Yo mama got the wooden leg with real feet",
"file2": "Yo mama's glasses so thick, when she looks at maps she can see people waving at her",
"file1": "Yo mama's an extra on the Simpsons"
}
var randomDelay = Math.floor((Math.random() * 10000));
console.log("Making Ajax request...");
setTimeout(function() {
cb(sampleResponses[url]);
}, randomDelay);
};
function output(text) {
console.log(text);
};
function getFile(file) {
// Write this thunk
};