Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
moonchie wants to merge1 commit intoironhack-labs:masterfrommoonchie:master

Conversation

moonchie
Copy link

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) {
Copy link

@ta-web-parista-web-parisMay 31, 2018
edited
Loading

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

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
Copy link

Good job!
Hope you like paying with function because you will have to use them a LOT ;)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ta-web-parista-web-parista-web-paris left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@moonchie@ta-web-paris@shankachu

[8]ページ先頭

©2009-2025 Movatter.jp