From 886d083cb95be47957c3cf33dd1fc3a452ab4250 Mon Sep 17 00:00:00 2001 From: Kristyn Bryan Date: Fri, 27 May 2016 15:02:16 -0400 Subject: [PATCH] Update Solution.js --- unit_01/w03d02/morning_exercise/Solution.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/unit_01/w03d02/morning_exercise/Solution.js b/unit_01/w03d02/morning_exercise/Solution.js index 3a21f7b..f07bf5f 100644 --- a/unit_01/w03d02/morning_exercise/Solution.js +++ b/unit_01/w03d02/morning_exercise/Solution.js @@ -1,4 +1,6 @@ -// least efficient - WHY? Could you see a situation where this could be inefficient? +// SOLUTION 1 +// least efficient +//WHY? Could you see a situation where this could be inefficient? // in this one, you're creating two loops. The first loop holds on to one index number (position 0) and the second loop compares it to every other number in the loop (index 0, 1, 2, etc.) var difference = function(arr){ var biggest = 0 @@ -14,6 +16,9 @@ var difference = function(arr){ console.log(difference([1, 4, 6, 2, 9])) +/////////////////////////////////////////////////////////////////////// + +// SOLUTION 2 // more efficient var diff = function(arr){