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
/** | |
* @description | |
* sumMaker(2,3)(4,5)(6,7) | |
* Above operation yields 27 | |
*/ | |
function sumMaker() { | |
var sumMain = Array.prototype.reduce.call(Array.prototype.slice.call(arguments), function(acc, curr) { | |
return acc + curr | |
}); |
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.prototype.bind = function(othis) { | |
// Check of 'this' is a function | |
if (typeof this !== 'function') { | |
throw new Error('What is trying to be bound is not callable'); | |
} | |
var args = Array.prototype.slice.call(arguments, 1); | |
var fNOP = function() {}; | |
var fToBind = this; | |
var boundFn = 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
// Flatten array function | |
// @arguments array | |
function flatten(arr) { | |
var newArr = []; | |
for (let i = 0; i < arr.length; i++) { | |
if (arr[i]) { | |
if (Array.isArray(arr[i])) { | |
newArr = newArr.concat(flatten(arr[i])); // Recursive call to flatten | |
} else { | |
newArr.push(arr[i]); |
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
{ | |
"editor.formatOnSave": true, | |
"beautify.config": { | |
"end_with_newline": true, | |
"wrap_line_length": 80, | |
"indent_handlebars": true, | |
"indent_inner_html": true, | |
"wrap_attributes": "force-aligned", | |
"newline_between_rules": true, | |
"space_around_combinator": 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
// Breadth First Search on graph | |
let BFS = (graph, startItem, callBack) => { | |
if (!graph[startItem]) { return false; } | |
let searched = []; | |
let currentQueue = []; | |
currentQueue.push(startItem); | |
while (currentQueue.length && currentQueue.length > 0) { | |
let currentNode = currentQueue.shift(); |
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
/** | |
* HashTable in JS | |
**/ | |
/** | |
* @description hashnode | |
*/ | |
class HashNode { | |
constructor(key, value, next) { | |
this.key = key; |
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
/** | |
* Binary Tree in javascript | |
**/ | |
class BST { | |
constructor(value) { | |
this.value = value; | |
this.right = null; | |
this.left = null; | |
} |
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
/** | |
* | |
* Linked List in javascript | |
* | |
**/ | |
/** | |
* | |
* Class node | |
* | |
**/ |
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
/** | |
* HourGlassProblem Class | |
*/ | |
class HourGlassProblem { | |
/** | |
* HourGlassProblem class constructor | |
* @param {Array} hourGlassCollection | |
*/ | |
constructor(hourGlassCollection) { |