Javascript number base converter