All files password.js

73.68% Statements 14/19
50% Branches 5/10
80% Functions 4/5
76.47% Lines 13/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 29 30 31 321x 5x   1x 4x 4x 7x   1x   1x 1x   1x             1x 1x     1x              
const checklength = function (password) {
  return password.length >= 8 && password.length <= 25
}
const checkAlphabet = function (password) {
  const alphabets = 'abcdefghijklmnopqrstuvwxyz'
  for (const ch of password) {
    if (alphabets.includes(ch.toLowerCase())) return true
  }
  return false
}
const checkDigit = function (password) {
  return /[1-9]/.test(password)
}
const checkSymbol = function (password) {
  const symbols = '!"#$%&()*+,-./:;<=>?@[]^_`{|}~'
  for (const ch of password) {
    if (symbols.includes(ch.toLowerCase())) return true
  }
  return false
}
const checkPassword = function (password) {
  return checklength(password) && checkAlphabet(password) && checkDigit(password) && checkSymbol(password)
}
 
module.exports = {
  checklength,
  checkAlphabet,
  checkDigit,
  checkSymbol,
  checkPassword
}