Skip to content

Commit 26b2545

Browse files
authoredAug 14, 2022
sixth commit
1 parent 7b16a00 commit 26b2545

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
 

‎beginner/ex13.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Have the function simpleAdding(num) add up all the numbers from 1 to num. For
3+
* example: if the input is 4 then your program should return 10 because 1 + 2 +
4+
* 3 + 4 = 10. For the test cases, the parameter num will be any number from 1
5+
* to 1000.
6+
*/
7+
8+
function simpleAdding(num) {
9+
let sum = 0;
10+
for (let i = 1; i <= num; i++) {
11+
sum += i;
12+
}
13+
return sum;
14+
}
15+
16+
console.log(simpleAdding(4));

0 commit comments

Comments
 (0)