## Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

### Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

# How to reuse functions?

I am playing around with some JavaScript and am trying to reuse some functions I've created in the code bellow. However if I add another scores array and try to reuse the functions with the new items, the previous array gets overridden by the second one.

How can I add more arrays and reuse the functions here?

```var scores = [
60, 50, 60, 58, 54, 54,
58, 50, 52, 54, 48, 69,
34, 55, 51, 52, 44, 51,
69, 64, 66, 55, 52, 61,
46, 31, 57, 52, 44, 18,
41, 53, 55, 61, 51, 44
];

var scores = [
50, 10, 20, 40
];

function printAndGetHighScore(scores) {
var highScore = 0;
var output;

for( i = 0; i < scores.length; i++) {
output = "Bubble solution #" + i + " score: " + scores[i];
console.log(output);

if(scores[i] > highScore) {
highScore = scores[i];
}
}

return highScore;

}
var highScore = printAndGetHighScore(scores);

function printHighestScore(scores, highScore) {
var bestSolutions = [];

for( i = 0; i < scores.length; i++) {
if (scores[i] == highScore) {
bestSolutions.push(i);
}
}
return bestSolutions;
}

var bestSolutions = printHighestScore(scores, highScore);

// show total scores
var totalScores = scores.length;
console.log("Bubble tests: " + totalScores);
console.log("Highest bubble score: " + highScore);
console.log("Solutions with highest score: " + bestSolutions);
```