I wanted to make a function in JS that validates a password. The password must have at least 8 and at most 32 characters, at least one uppercase letter, one lowercase letter and a number. Also it should return 1 when it fulfills all requirements and 0 when it doesn't.
My program returns a boolean value, but even when it's true, it keeps returning 0. What should I do?
var validatePassword = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])([0-9a-zA-Z]{8,32})$/
console.log(validatePassword.test("Password10"))
if (validatePassword == true) {
console.log("1")
}
else {
console.log("0")
}