Code Example
const scores = [78, 89, 95, 91];
const boosted = scores.map(score => score + 2);
const total = boosted.reduce((sum, score) => sum + score, 0);
console.log("Boosted scores:", boosted.join(", "));
console.log("Average:", (total / boosted.length).toFixed(2));
Expected Output
Boosted scores: 80, 91, 97, 93
Average: 90.25
Practice Steps
- Open the JavaScript compiler and paste the code.
- Run it once, then change the score values.
- Add another array method such as filter() and inspect the terminal output.