Skip to content

Commit 5f5ad43

Browse files
authored
Create RunningSumof1dArray.js
1 parent 2907940 commit 5f5ad43

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

RunningSumof1dArray.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {number[]}
4+
*/
5+
var runningSum = function(nums) {
6+
let resultArray = [];
7+
for(let x = 0; x < nums.length; x++)
8+
{
9+
let sumForInside = 0;
10+
for(let y = 0; y <= x; y++)
11+
{
12+
//console.log(nums[y])
13+
sumForInside += nums[y]
14+
}
15+
resultArray.push(sumForInside)
16+
}
17+
//console.log(resultArray);
18+
return resultArray
19+
};
20+
21+
runningSum([1,2,3,4])

0 commit comments

Comments
 (0)