JavaScript: Base 10 to Another Base and Vice Versa