- Notifications
You must be signed in to change notification settings - Fork6.7k
PAR Valérie Linarès & Shanshan Cao#414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
var numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10]; | ||
var sum = 0; | ||
function sumArray(target){ | ||
var result = target.reduce(function(accumulator, currentValue, currentIndex, array) { |
ta-web-parisMay 31, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
To resolve the error in jasmine just add this two lines of code :
if(target.length==0){sum=0returnsum;}
Because the jasmine want's you to deal with special case like this (empty array, ect..)
// Calculate the Average | ||
var numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9]; | ||
function averageNumbers(target){ | ||
sumArray(target); //get the sum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Same here you should add a condition, so when target is empty you return undefined
ta-web-paris commentedMay 31, 2018
Good job! |
@valerielinares