Skip to content

Commit b197372

Browse files
committed
Refactor : naming.
Not necessarily the best solutions, just the relevant indexes (given the score to match).
1 parent 62b87c0 commit b197372

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

scratch/chapter4/bubble.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,22 @@
6464
scores, prices, scoreToMatch) {
6565

6666
// the indexes of the solutions with highest scores
67-
var bestSolutions = indexesWithValue(scores, scoreToMatch);
67+
var relevantScoreIndexes = indexesWithValue(scores, scoreToMatch);
6868

6969
// seed lowestPrice with the first relevant
70-
var lowestPrice = prices[ bestSolutions[0] ];
70+
var lowestPrice = prices[ relevantScoreIndexes[0] ];
7171

7272
var cheapestSolutionsWithScore = [];
7373

74-
for (var i = 0; i < bestSolutions.length; i++) {
75-
if (prices[ bestSolutions[i] ] < lowestPrice) {
74+
for (var i = 0; i < relevantScoreIndexes.length; i++) {
75+
if (prices[ relevantScoreIndexes[i] ] < lowestPrice) {
7676
lowestPrice = prices[i];
7777
}
7878
}
7979

80-
for (var i = 0; i < bestSolutions.length; i++) {
81-
if (prices[ bestSolutions[i] ] == lowestPrice) {
82-
cheapestSolutionsWithScore.push(bestSolutions[i]);
80+
for (var i = 0; i < relevantScoreIndexes.length; i++) {
81+
if (prices[ relevantScoreIndexes[i] ] == lowestPrice) {
82+
cheapestSolutionsWithScore.push(relevantScoreIndexes[i]);
8383
}
8484
}
8585

0 commit comments

Comments
 (0)