Skip to content

Commit 7165d34

Browse files
committed
added a code that would throw error when element is not array
1 parent c4a0488 commit 7165d34

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎Sprint-1/implement/sum.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
function sum(elements) {
2+
if (!Array.isArray(elements)) {
3+
throw new Error("sum requires an array of numbers");
4+
}
25
for (const num of elements) {
36
if (typeof num !== "number") {
47
throw new Error("sum requires an array of numbers");

0 commit comments

Comments
 (0)