Skip to content

Commit 7e641d5

Browse files
committed
Refactor : pass in high score.
Removes one extraneous computation of the high score.
1 parent 822e804 commit 7e641d5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

scratch/chapter4/bubble.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
console.log("Highest scoring solutions: " +
2727
indexesWithValue(scores, bestBubbleScore) );
2828
console.log("Cheapest of highest scoring solutions: " +
29-
indexesOfCheapestSolutionsWithHighestScore(scores, prices));
29+
indexesOfCheapestSolutionsWithHighestScore(
30+
scores, prices, bestBubbleScore));
3031

3132

3233

@@ -59,10 +60,9 @@
5960

6061

6162

62-
function indexesOfCheapestSolutionsWithHighestScore(scores, prices) {
63-
64-
var highestScore = computeMaximum(scores);
65-
63+
function indexesOfCheapestSolutionsWithHighestScore(
64+
scores, prices, highestScore) {
65+
6666
// the indexes of the solutions with highest scores
6767
var bestSolutions = indexesWithValue(scores, highestScore);
6868

0 commit comments

Comments
 (0)