SHARE
TWEET

Untitled

a guest Apr 26th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*do not understand why i = 1 instead of 0 as this means the loop begins iterating on the second item in the array*/
  2.  
  3. function average(numbers) {
  4.   let total = numbers[0];
  5.   for (let i = 1; i < numbers.length; i++) {
  6.     total += numbers[i];
  7.   }
  8.   return total / numbers.length;
  9. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top