Minor JS bug: invalid string in comparison