This logic will not work for [1 -1 0]. Could you adjust it to "match" comment: make isDashArrayValid == true initially, and scan all items to find non-positive value to reset it to false? `if (!(+dashArray[i] > 0)) {' shall catch non-numbers and non-positive numbers