-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (20 loc) · 754 Bytes
/
index.js
File metadata and controls
28 lines (20 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const fetchData = async () => {
const data = await fetch('https://codember.dev/data/encryption_policies.txt');
const text = await data.text();
const passwords = text.split('\n');
resolve(passwords);
};
const resolve = (passwords) => {
let invalidPasswords = [];
passwords.forEach((password) => {
const passSpliced = password.split(' ');
const [min, max] = passSpliced[0].split('-');
const letter = passSpliced[1].replace(':', '');
const passwordToCheck = passSpliced[2];
let minLetter = passwordToCheck.split('').filter((l) => letter === l).length;
let isValid = minLetter >= min && minLetter <= max;
!isValid && invalidPasswords.push(passwordToCheck);
});
return invalidPasswords[41];
};
fetchData();