Skip to content

Instantly share code, notes, and snippets.

View betterkenly's full-sized avatar

Kenly Hui betterkenly

  • San Francisco
View GitHub Profile
@betterkenly
betterkenly / hasPathToSum
Created June 22, 2017 16:52
hasPathToSum
const hasPathToSum = function(node, targetSum) {
// your code here
// let search = (node, val) => {
// if (node.value === null) {
// return;
// }
// if (val === targetSum) {
// return true;
// var cashAmount = function(value) {
// this.value = value;
// }
// cashAmount.prototype.totalInPennies = function() {
// return this.value * 100;
// }
// const cash = new cashAmount(10.50);
// cash.totalInPennies(); // -> 1050
@betterkenly
betterkenly / gist:5eaeac94bee2b48277ac4249f38d21ef
Created June 8, 2017 16:56
probably correct approach but wrong execution, need to refine JS skill and logic. and focus on tree. poor
const findLargestLevel = function(node) {
var queue = [];
node.level = 0;
queue.push(node);
var current;
var largest;
var salesTeam = [{name: {first: 'aleen', last: 'atkins'}, age: 26, sales: '$2314'},
{name: {first: 'alvaro', last: 'angelos'}, age: 55, sales: '$1668'},
{name: {first: 'denese', last: 'dossett'}, age: 29, sales: '$9248'},
{name: {first: 'douglas', last: 'denney'}, age: 53, sales: '$5058'},
{name: {first: 'earline', last: 'erickson'}, age: 19, sales: '$18876'},
{name: {first: 'herman', last: 'hazell'}, age: 25, sales: '$2746'},
{name: {first: 'homer', last: 'hirth'}, age: 26, sales: '$474'},
{name: {first: 'hwa', last: 'heidt'}, age: 53, sales: '$9607'},
{name: {first: 'hyon', last: 'hampshire'}, age: 46, sales: '$13598'},
_.extend = function(obj){
_.each(arguments, function(argObj){
_.each(argObj, function(value, key ){
return obj[key] = value;
});
});
return obj;
}
@betterkenly
betterkenly / gist:cfd512ca05f2f9170ba0ee81b18d5ee6
Created April 21, 2017 03:42
Kenly Hui/ assessment3 answer;
// Write a function that takes 3 words and returns a single count of all their letters.
function combinedCharacterCount(word1, word2, word3){
var together = word1 + word2 + word3;
return together.length;
}
// Below is a simple assert function and its invocation. Add this to your code and make sure that the test passes.