You seem to already know how to generate a pseudo-random integer, so then all you need to do is base64 encode it.
Be aware though that JavaScript's pseudo-random number generator is not cryptographically strong so an attacker who can run JS in the browser at the same time you're generating your ID may be able to guess with relatively high likelihood the number you generate.