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 / 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.
_.extend = function(obj){
_.each(arguments, function(argObj){
_.each(argObj, function(value, key ){
return obj[key] = value;
});
});
return obj;
}
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'},
@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 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 / 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 kthSmallest = function(root, k) {
var result = [];
var search = (node) => {
if (node.val !== null) {
result.push(node.val);
}
if (node.left) {
search(node.left);
}
if (node.right) {
function productExceptSelf(arr){
var temp = [];
var product = 1;
for(var i = 0; i < arr.length; i++){
temp[i] = product;
product *= arr[i];
}
var arr = 'what on earth are you talking about'.split('');
// var vowelDoubler = (str) => {
// return str.replace(/[a||e||i||o||u]/gi, myFunc).split('');
// };
var vowelTest = (str) => {
if (str.match(/[a||e||i||o||u]/gi)) {
return true;
let messageBus = {
subscribers: [],
publish: (message) => {
this.subscribers.forEach((subscriber) => {
subscriber.fn(message);
});
},
subscribe: (type, subscriber, fn) => {
this.subscribers.push({
'type': type,