Skip to content

Commit 64630ac

Browse files
committed
Add fix for '1' argument
1 parent 898b9a0 commit 64630ac

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

RandSum0/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ class genSum {
3131
}
3232
sumArray() {
3333
if (this.array.length) {
34-
return this.array.reduce((a, b) => a + b)
34+
if (this.array.length == 1) {
35+
return this.array[0]
36+
} else {
37+
return this.array.reduce((a, b) => a + b)
38+
}
3539
} else {
3640
return this.array
3741
}

0 commit comments

Comments
 (0)