Write a function isValidPassword(password) that checks the length of a password. The parameter password is a string.
true if the password has from 20 to 40 characters. Both 20 and 40 are valid.false if it has fewer than 20 or more than 40 characters. The empty string '' has 0 characters, so it is not valid.The result is a boolean: true or false. The passwords in the tests have only simple characters: letters, digits, spaces and signs like !.
isValidPassword('MySecretPassword2024')Returns true
isValidPassword('qwerty')Returns false
isValidPassword(' my long password ')Returns true
Asked at EPAM · Source
isValidPassword('MySecretPassword2024')trueisValidPassword('correct horse battery staple')trueisValidPassword('qwerty')falseisValidPassword('this password is way too long to be accepted')falseisValidPassword('my-password.is_long, ok?')trueHidden tests run on Submit.