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 Human { | |
| constructor (firstName, lastName) { | |
| this.firstName = firstName | |
| this.lastName = lastName | |
| } | |
| } | |
| let human1 = new Human("rachel", "green") | |
| let human2 = new Human("ross", "geller") |
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
| package.json | |
| ``` | |
| ... | |
| "moduleRoots": [ | |
| "", | |
| "custom-resolver.js" | |
| ], | |
| "devDependencies": { | |
| "@babel/plugin-proposal-class-properties": "^7.3.0", | |
| "@babel/plugin-syntax-jsx": "^7.2.0", |
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
| /* | |
| Depth-first search | |
| a | |
| / \ | |
| b c | |
| /|\ \ | |
| d e f g | |
| | | |
| h |
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 sendSignedTransaction(web3, privateKey, nonce, gasPrice, gasLimit, to, from, data) { | |
| try { | |
| const rawTx1 = { | |
| nonce: nonce, | |
| gasPrice: gasPrice, | |
| gasLimit: gasLimit, | |
| to: to, | |
| from: from, | |
| data: 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
| function rps(rounds) { | |
| var obj = {} | |
| var feed = ['r','p','s']; | |
| function recurse(combo, numRoundsLeft) { | |
| if(!numRoundsLeft) { | |
| obj[combo] = 1 | |
| return | |
| } | |
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 anagram(str) { | |
| var obj = {} | |
| function recurse(combo, feed) { | |
| if(!feed.length) { | |
| obj[combo] = 1 | |
| return | |
| } else { | |
| for(var i=0; i < feed.length; i++) { | |
| recurse(combo+feed[i], feed.slice(0,i) + feed.slice(i+1)) | |
| } |
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 mergeIntervals(intervals) { | |
| if(intervals.length < 2) return intervals | |
| intervals = intervals.sort(function(a,b) { | |
| return a[0] - b[0] | |
| }) | |
| var stack = [] | |
| stack.push(intervals[0]) | |
| var top | |
| for(var i = 1; i < intervals.length; i++) { | |
| top = stack[stack.length - 1] |
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 count(file) { | |
| var lines = file.split("\n") | |
| var wordToCounterMap = {} | |
| var wordToLineMap = {} | |
| for(var k = 0; k < lines.length; k++) { | |
| countWords(lines[k].split(" "), k) | |
| } | |
| function countWords(words, lineNumber) { |
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
| //detect pangram (has all alphabet characters) | |
| function isPangram(string){ | |
| var alphabets = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z" | |
| var a = alphabets.split(",") | |
| string = string.replace(/[^a-zA-Z0-9]+/g,"").toLowerCase() | |
| for(var i=0;i<a.length;i++) { | |
| if(string.indexOf(a[i]) === -1) return false; | |
| } | |
| return 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
| //find count of most frequent item in array | |
| function mostFrequentItemCount(store) { | |
| var frequency = {} | |
| var max = 0; | |
| var result; | |
| for (var v in store) { | |
| frequency[store[v]] = (frequency[store[v]] || 0)+1; | |
| if(frequency[store[v]] > max) { | |
| max = frequency[store[v]]; | |
| // result = store[v]; |
NewerOlder