Below given function will generate a random password including special characters.
function generatePswdString(max, min) {
const passwordChars = “0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#@!%& ()/”;
const randPwLen = Math.floor(Math.random() * (max – min + 1)) + min;
var randomPassword = “”;
for (var i = 0; i < randPwLen; i++) {
var randomIndex = Math.floor(Math.random() * (passwordChars.length));
randomPassword += passwordChars.charAt(randomIndex);
}
log.debug(“randomPassword”, randomPassword);
return randomPassword;
}