From 8bd640cf5e5fcd037c5c342c851f57d4a6b619a7 Mon Sep 17 00:00:00 2001 From: badra25ml Date: Thu, 11 Jun 2015 15:06:07 -0700 Subject: [PATCH 1/2] Delete index.js --- index.js | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 index.js diff --git a/index.js b/index.js deleted file mode 100644 index 9bb9cd7..0000000 --- a/index.js +++ /dev/null @@ -1,6 +0,0 @@ -var doubler = function(a, b) { -} - -console.assert(doubler(4,2) === 12); -console.assert(doubler(1,3) === 8); -console.assert(doubler(-1,3) === 4); From d5a018161f8c2811443d2ebd49ffab18887b8dd4 Mon Sep 17 00:00:00 2001 From: badra25ml Date: Thu, 11 Jun 2015 17:28:51 -0700 Subject: [PATCH 2/2] Create index.js --- index.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..30ec052 --- /dev/null +++ b/index.js @@ -0,0 +1,33 @@ +var doubler = function(a, b) { + if(typeof b === "function" ){ + return b()*2+a()*2; + } + 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; } +function m1() {return 1; } + +console.assert(doubler(m4, m2) === 12); +console.assert(doubler(m1, m3) === 8); + +function objectsEqual() {return a != b;} + +var a = { z: 42 , t: 7 }, b = { t: 7, z: 42 }; + +console.assert(objectsEqual(a, b)); +console.assert(objectsEqual(b, a)); + +objectsEqual(doubler({x1: 1, x2: 4}), {x1: 2, x2: 8}); +objectsEqual(doubler({x1: -4, x2: 0}), {x1: -8, x2: 0}); + +//console.log(Object.keys(a).reverse());