Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function practice(param) {
- let minCharacters = param.match(/.{6,10}/g);
- let onlyLetters = param.match(/[A-Za-z\d]+/g);
- let atLeast2Digits = param.match(/\d/g);
- let isValid = true;
- if (!minCharacters) {
- console.log('Password must be between 6 and 10 characters');
- isValid = false;
- }
- if (onlyLetters == null || onlyLetters[0] !== param) {
- console.log('Password must consist only of letters and digits');
- isValid = false;
- }
- if (!atLeast2Digits || atLeast2Digits.length < 2) {
- console.log('Password must have at least 2 digits');
- isValid = false;
- }
- if (isValid) {
- console.log('Password is valid');
- }
- }
- practice('------')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement