Why isn't my function returning 0 for an empty array in JavaScript

visit shbcf.ru