How to make a password generator in JavaScript?

To make a password generator in JavaScript, do this: (Math.random() || 0.001).toString(36).slice(2).

Here's how you do it:

function getNewPassword() {
  return (Math.random() || 0.001).toString(36).slice(2);
}

function getNewLongPassword() {
  return getNewPassword() + getNewPassword() + getNewPassword() + getNewPassword();
}

const password = getNewPassword();
const longPassword = getNewLongPassword();

// diufiuy6uo
// lqo7bmg0ew
// ad2sh7bbej
// …
console.log(password);

// jm1i0otsxyruwxybyzxlgxhyt57xhw49ulufzeuvned
// wu247bj9d6q56v7zrruamtfx9232vhs64fxgzosr1io7
// tjcd7rw30hg5g91rcpq9pyupo2tnwg47ihaqbkiewuko
// …
console.log(longPassword);