We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8aae3f8 commit 214e442Copy full SHA for 214e442
Sprint-1/implement/sum.js
@@ -3,8 +3,8 @@ function sum(arr) {
3
4
for (let element of arr) {
5
// iterate through each element in the array
6
- if (typeof element === "number") {
7
- // check if the element is a number
+ if (Number.isFinite(element)) {
+ // check if the element is a number, without counting NaN or Infinity
8
total += element; // add the number to the total sum
9
}
10
0 commit comments