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
| //Generators | |
| // Remember functions? | |
| function doA() { | |
| console.log('did A'); | |
| } | |
| function doB() { | |
| console.log('did B') | |
| } | |
| function justAFxn() { |
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
| getOpenGraph: function(req, res) { | |
| console.log(req.body.url); | |
| openGraph(req.body.url, function(err, meta) { | |
| if (err) { | |
| console.error(err); | |
| } else { | |
| res.send(meta); | |
| } | |
| }); | |
| }, |
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 a() { | |
| setTimeout(function() { | |
| console.log('a'); | |
| b(); | |
| }, 2000); | |
| }; | |
| function b() { | |
| setTimeout(function() { |
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 a() { | |
| setTimeOut(function() { | |
| console.log('a'); | |
| b(); | |
| }, 2000); | |
| }; | |
| function b() { | |
| setTimeOut(function() { | |
| console.log('b'); |
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 a() { | |
| console.log('a'); | |
| } | |
| function b() { | |
| console.log('b'); | |
| } | |
| function c() { | |
| console.log('c'); |
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 a() { | |
| setTimeOut(function() { | |
| console.log('a'); | |
| b(); | |
| }, 2000); | |
| }; |
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
| fetchFile = (filePath) => { | |
| return new Promise((resolve, reject) => { | |
| readFile(filePath, (err, contents) => { | |
| if (err) { return reject(err); } | |
| }); | |
| resolve(contents); | |
| }).then(); | |
| }; |
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
| // A S Y N C H R O N O U S FXN USING A C A L L B A C K | |
| var fetchFile = function(filePath, callback) { | |
| readFile(filePath, (err, contents) => { | |
| if (err) { | |
| return callback(err); | |
| } else { | |
| callback(contents); | |
| } | |
| }); | |
| }; |
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 bubbleSort(array) { | |
| var i, j; | |
| for (i = array.length - 1; i >= 0; i--) { | |
| for (j = 0; j <= i; j++) { | |
| if (array[j + 1] < array[j]) { | |
| var temp = array[j]; | |
| array[j] = array[j + 1]; | |
| array[j + 1] = temp; | |
| } | |
| } |
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
| let binaryBubbleSort = (array) => { | |
| var lowIndex = array[0]; | |
| var highIndex = array[array.length -1]; | |
| var timesThrough = 0; | |
| while (lowIndex <= highIndex){ | |
| var middleIndex = (highIndex + lowIndex) / 2; | |
| if (array[middleIndex] < value) { | |
| lowIndex = middleIndex + 1; | |
| } else if (array[middleIndex] > value) { |