Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*do not understand why i = 1 instead of 0 as this means the loop begins iterating on the second item in the array*/
- function average(numbers) {
- let total = numbers[0];
- for (let i = 1; i < numbers.length; i++) {
- total += numbers[i];
- }
- return total / numbers.length;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement