Created
March 29, 2023 05:35
-
-
Save NAZIMUDHEEN267/c61dbaf139587a2c7fc4d242a7a9a74f to your computer and use it in GitHub Desktop.
Get all the numbers sum that passed on the "runningSum" function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function runningSum(nums: number[]): number[] { | |
let sum = [nums[0]]; | |
for(let i=1; i<nums.length; i++) { | |
sum[i] = sum[i-1] + nums[i]; | |
} | |
return sum; | |
} | |
runningSum([1,2,3,4,5,6,7,8,9,10) // return [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment