Skip to content

Commit c44ac8f

Browse files
author
shmidtkirill
committed
Added empty array check
Added empty array check to the second ("right") solution.
1 parent 72528a3 commit c44ac8f

File tree

1 file changed

+1
-0
lines changed
  • 1-js/4-data-structures/9-array-iteration/2-partial-sums-array

1 file changed

+1
-0
lines changed

1-js/4-data-structures/9-array-iteration/2-partial-sums-array/solution.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ alert(getSums([1,2,3,4,5])); // результат: *!*1,3,6,10*/!*
3131
//+ run
3232
function getSums(arr) {
3333
var result = [];
34+
if (!arr.length) return result;
3435

3536
*!*var totalSum*/!* = arr.reduce(function(sum, item) {
3637
result.push(sum);

0 commit comments

Comments
 (0)