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

Commit 96babc3

Browse files
Merge pull request #4 from anasmak04/master
add problem 39
2 parents 3a55d8c + 171121f commit 96babc3

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

‎README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@
4040
| Problem - 36 | [Rock Paper Scissors](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-36.js) |
4141
| Problem - 37 | [sum of an array](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-37.js) |
4242
| Problem - 38 | [biggest number of an array](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-38.js) |
43+
| Problem - 39 | [sum of n numbers with one argument ](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-39.js) |
4344

44-
<!-- | Problem - 39 | | -->
45+
<!-- | Problem - 40 | | -->

‎problem-39.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// create a function that take one argument and return sum n numbers
2+
3+
4+
function sum(...args){
5+
return args.reduce((a,b) => {
6+
return a + b;
7+
},0)
8+
}
9+
10+
let result = sum(2,1,5,6,8);
11+
console.log(result);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /