Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Created April 22, 2020 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/bc485441c2ae180c9c7ddb587edb0fed to your computer and use it in GitHub Desktop.
Save McLarenCollege/bc485441c2ae180c9c7ddb587edb0fed to your computer and use it in GitHub Desktop.

Strong Password

Time allowed: 25 mins

Create a function that takes a candidate password and returns the minimum number of extra characters needed to make it a strong password.

A password is considered strong if it satisfies the following criteria:

  • Its length is at least 6.
  • It contains at least one digit.
  • It contains at least one lowercase English character.
  • It contains at least one uppercase English character.
  • It contains at least one special character: !@#$%^&*()-+

Types of characters in a form you can paste into your solution:

const numbers = "0123456789"
const lower = "abcdefghijklmnopqrstuvwxyz"
const upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
const special = "!@#$%^&*()-+"

Examples

strongPassword(“Ed1”) ➞ 3
strongPassword(“#Edabit”) ➞ 1
strongPassword("W1llth!spass?") ➞ 0

Notes

Try solving this without RegEx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment