- Notifications
You must be signed in to change notification settings - Fork345
Open
Description
Hello everyone!
I've got a question about the final version of the code in Chapter 4 (root: Chapter 4 -> bubbles2.html). The function getMostCostEffectiveSolution(scores, costs, highScore) is meant to choose the lower price for the highest scores that repeat twice. The best costs turned out to be .22 and .25. As a result of invoking the built-in return function, we get .22, but how does the function understand that we need a lower price, though we didn't mention any condition for that?
function getMostCostEffectiveSolution(scores, costs, highScore) {
var cost = 100; // much higher than any of the costs
var index;
for (var i = 0; i < scores.length; i++) {if (scores[i] == highScore) {if (cost > costs[i]) {index = i;cost = costs[i];}}}return index;
}
Metadata
Metadata
Assignees
Labels
No labels