Because you've typo-ed "num_dirs" instead of "numdirs" on line assigning "dd".
Since this is JS, unset variable is equal to "undefined", math operations on it result in "NaN", and round(NaN) is... 1? Well.