Sitelet https://web.archive.org/web/20260524171247/https://github.com/TheAlgorithms/JavaScript/pull/1273
Skip to content

--sum-of-array#1273

Closed
Yerenzter wants to merge 1 commit into
TheAlgorithms:masterfrom
Yerenzter:patch-1
Closed

--sum-of-array#1273
Yerenzter wants to merge 1 commit into
TheAlgorithms:masterfrom
Yerenzter:patch-1

Conversation

@Yerenzter
Copy link
Copy Markdown

I propose a built-in JavaScript function which is sum() that sum all the lengths of an array.

let sum = (y) => {
        let sum = 0;

        for(r=0; r<y.length; r++) {
                sum += y[r];
        }

        return sum;
};

Copy link
Copy Markdown
Collaborator

@appgurueu appgurueu left a comment

Choose a reason for hiding this comment

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

  • Missing tests.
  • Improper formatting; poor variable naming; r is global.
  • Missing documentation.
  • Consider using reduce for a one-liner or alternatively using the for-of loop construct.
  • Might be too trivial to warrant inclusion; not sure about that yet.

Please refer to our contribution guidelines.

@stale
Copy link
Copy Markdown

stale Bot commented Jun 18, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the stale Closed due to age label Jun 18, 2023
@appgurueu appgurueu added the invalid Doesn't seem right label Jun 18, 2023
@appgurueu appgurueu closed this Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid Doesn't seem right stale Closed due to age

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants