javascript
Arrays and loops
An array is JavaScript's version of a list:
const scores = [12, 7, 30, 18];
console.log(scores[0]); // 12
console.log(scores.length); // 4
scores.push(25); // add at the end
for (const score of scores) {
console.log("Score:", score);
}
And if you need to count, there's the classic for loop:
for (let i = 0; i < 5; i++) {
console.log("Lap", i);
}
It reads: start with i at 0; keep going while i is less than 5; add 1 to i after each lap.
Your mission
Using loops (no Math.max allowed, that would be cheating 😉):
total(numbers)returns the sum of the numbers (0for an empty array).biggest(numbers)returns the largest number.