diff --git a/index.js b/index.js index 3b24cd5..9cc03ba 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,26 @@ var doubler = function(a, b) { + 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); console.assert(doubler(1,3) === 8); 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 +29,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")