Skip to content

Conversation

juliemnrd
Copy link

@alice.dbrg

var average = sumAverage/array.length
}
return average
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep your code dry (= avoid repetitions), you can also call the sumArray function that you created earlier.

function averageNumbers(arrayNumber) {
   var sumRes = sumArray(arrayNumber);
   if (arrayNumber.length > 0) {
   var average = sumRes / arrayNumber.length; 
   }
   return average;
 }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the if statement here ( if (arrayNumber.length > 0) ) is to handle the case when we try to pass an empty array to the function, to please Jasmine :)

@ta-web-paris
Copy link

ta-web-paris commented Aug 8, 2018

The logic is good, remember to indent your code to improve its readability.
Also, remember to change the name of your pull requests to PAR Julie and Alice, otherwise we might miss it :)
Good work!

@juliemnrd juliemnrd changed the title done PAR Alice & Julie Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants