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
name = 'Kavit'; | |
var team = { | |
name: 'Kevin', | |
member: { | |
name: 'Nik', | |
getName: function () { | |
return this.name; | |
} | |
} |
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
class LinkedList { | |
constructor() { | |
this.head = null; | |
} | |
insertNodeAtTail(val) { | |
var node = { | |
data: val, |
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'; | |
function stepsToSolveHanoiT(height, srcP, desP, bufferP) { | |
if (height >= 1) { | |
// Move a tower of height-1 to the buffer peg, using the destination peg. | |
stepsToSolveHanoiT(height - 1, srcP, bufferP, desP); | |
// Move the remaining disk to the destination peg. |
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 Queue () { | |
this.first = null; | |
this.last = null; | |
} | |
Queue.prototype.enqueue = function (val) { | |
var q1 = { | |
data : val, | |
next : 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
'use strict'; | |
function BinarySearchTree() { | |
this.root = null; | |
} | |
BinarySearchTree.prototype.insertNode = function (val) { | |
var node = { | |
data : val, |
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"; | |
function createHalfPyramid (height) { | |
for (var i = 1; i <= height; i++) { | |
var row = ''; | |
for (var j = 1; j <= (height - i); j++) { | |
row += ' '; | |
} |
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'; | |
function compressArr (arr) { | |
var start = arr[0]; | |
var stop = start; | |
var arrLength = arr.length; | |
var result = ''; | |
for (var i = 1; i < arrLength; 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
'use strict' | |
function f1 () { | |
console.log('f1 called'); | |
return false; | |
} | |
function f2 () { | |
console.log('f2 called'); |
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
// Returns a function, that, as long as it continues to be invoked, will not be triggered. | |
// The function will be called after it stops being called for N milliseconds. | |
function debounce (cb, wait) { | |
var timeoutID | |
return function () { | |
clearTimeout(timeoutID) | |
timeoutID = setTimeout(cb, wait) | |
} |
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'; | |
var express = require('express'); | |
var compression = require('compression'); | |
var app = express(); | |
var oneYear; | |
// gzip the static resources before seding to browser, if the browser supports gzip compression |