JavaScript Essentials → Functions & Scope
Function Declarations
Type the code below
function calculateTotal(items) {
let sum = 0;
for (let item of items) {
sum += item.price;
}
return sum;
}Live metrics
WPM
0
Accuracy
100.0%
Time
0:00
Errors
0
Sign in to save your progress and appear on the leaderboard.