diff --git a/unit_01/w03d02/morning_exercise/Solution.js b/unit_01/w03d02/morning_exercise/Solution.js index 409146a..3a21f7b 100644 --- a/unit_01/w03d02/morning_exercise/Solution.js +++ b/unit_01/w03d02/morning_exercise/Solution.js @@ -1,5 +1,6 @@ -// least efficient -var diff = function(arr){ +// 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 for (var i = 0; i < arr.length; i++) { for (var j = 0; j < arr.length; j++) { @@ -11,7 +12,7 @@ var diff = function(arr){ return biggest } -console.log(diff([1,4, 6, 2, 9])) +console.log(difference([1, 4, 6, 2, 9])) // more efficient