Skip to content

Commit 3b4fb99

Browse files
committed
add new problem
1 parent 812f095 commit 3b4fb99

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
@@ -38,5 +38,6 @@
3838
| Problem - 34 | [Reverse numbers](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-34.js) |
3939
| Problem - 35 | [A needla in haystack](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-35.js) |
4040
| Problem - 36 | [Rock Paper Scissors](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-36.js) |
41+
| Problem - 37 | [sum of an array](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-37.js) |
4142

42-
<!-- | Problem - 37 | | -->
43+
<!-- | Problem - 38 | | -->

problem-37.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Take an array of integer data type of size 10 And pritn the sum of those 10 integers.
2+
3+
const solution = (array) => {
4+
let sum = array.reduce((acc,curr) => { return acc + curr},0)
5+
return sum;
6+
7+
};
8+
9+
console.log(solution([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])); // 55
10+
console.log(solution([22, 11, 55, 66, 77, 88, 99, 44, 33, 10 ])); // 505
11+
console.log(solution([12, 12, 65, 36, 87, 18, 79, 14, 73, 70 ])); // 466

0 commit comments

Comments
 (0)