From 7ef2c82fc2def70a0ba65319811ae51dbd3fd184 Mon Sep 17 00:00:00 2001 From: Elijah Olegnowicz Date: Thu, 11 Jun 2015 14:58:43 -0700 Subject: [PATCH 1/3] Update index.js --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 9bb9cd7..0c5aa34 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,5 @@ var doubler = function(a, b) { + return a*2 + b*2 } console.assert(doubler(4,2) === 12); From ce964853105ef4124d631a421e90d6d576fe06b9 Mon Sep 17 00:00:00 2001 From: Elijah Date: Thu, 11 Jun 2015 15:31:56 -0700 Subject: [PATCH 2/3] tever --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 60211f5..64da464 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ var doubler = function(a, b) { - return a + a + b + b; + return (a + b)*2; }; console.assert(doubler(4,2) === 12); From 5189359ee6b398edc5ac3862609ca989270e4352 Mon Sep 17 00:00:00 2001 From: Elijah Date: Thu, 11 Jun 2015 17:41:33 -0700 Subject: [PATCH 3/3] challenge --- index.js | 24 +++++++++++++++++++++--- tdd2.js | 5 +++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 tdd2.js diff --git a/index.js b/index.js index 0a65cd0..be6fc81 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,17 @@ var doubler = function(a, b) { - return (a + b)*2; + if(typeof(a) === 'function') { + a = a(); + }; + if(typeof(b) === 'function'){ + b = b(); + }; + if(typeof(a) === 'Object'){ + a = Objects.keys(a); + } + if(typeof(b) === 'Object'){ + b = Object.Keys(b); + } + return a + a + b + b; }; console.assert(doubler(4,2) === 12); @@ -8,7 +20,6 @@ console.assert(doubler(-1,3) === 4); console.assert(doubler("a", "b") === "aabb"); console.assert(doubler("coding", "rocks") === "codingcodingrocksrocks"); - function m3() { return 3; } function m4() { return 4; } function m2() { return 2; } @@ -17,7 +28,14 @@ function m1() { return 1; } console.assert(doubler(m4, m2) === 12); console.assert(doubler(m1, m3) === 8); -function objectsEqual() { } +function objectsEqual(a, b) { + + var aKeys = Object.keys(a); + var bKeys = Object.keys(b); + return aKeys.every(function(e, i){ + return aKeys[e]===bKeys[e]; + }); +}; var a = { z: 42 , t: 7 }, b = { t: 7, z: 42 } diff --git a/tdd2.js b/tdd2.js new file mode 100644 index 0000000..b484a54 --- /dev/null +++ b/tdd2.js @@ -0,0 +1,5 @@ + +NumberMultiplier(a, b){ +}; +console.assert(numberMultiplier("ten","five") === "fifty"); +console.assert(numberMultiplier("six","twenty") === "one hundred and twenty")