Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ChantalDemissie/7b797cfc0f99f03e86a7ec803e42cb90 to your computer and use it in GitHub Desktop.
Save ChantalDemissie/7b797cfc0f99f03e86a7ec803e42cb90 to your computer and use it in GitHub Desktop.
day4activities.rb
puts "Hello please create a password to access your account"
puts "This must include a letter, number and special characters and be 8 or more characters"
password_is_min_length = false
password_contain_special_character = false
password_contain_number = false
special_characters = %w[@ % * !]
until password_is_min_length \
&& password_contain_special_character \
&& password_contain_number
password = gets.chomp
password_is_min_length = password.length >= 8
special_characters.each do |special_character|
if password.include? special_character
password_contain_special_character = true
break
end
end
(0..9).each do |number|
if password.include? number.to_s
password_contain_number = true
break
end
end
end
puts "Valid Password congratulations!"
@brookskindle
Copy link

Hi Chantal,

Thank you for submitting the password verification exercise! Good work, below is some feedback/suggestions for you:

  • When submitting don't forget to use the .rb file extension for each of your files, not just the name of the gist
  • Clever ways of checking for the special characters and if the password contains a number or not.
    • If you haven't already and you're up for a challenge, I'd recommend looking up ruby regular expressions and seeing if you can modify your program to use them for the password checks
  • Nice job with the use of whitespace in your program - it's nicely laid out and easy to follow
  • Aside from the beginning and end prompt, there is no indication of what the user needs to do while they're entering their password. Put more puts prompts to more clearly indicate to the user what they are or are not doing correctly.

Hope this helps, please reach out to me if you have any questions. See you in class on Tuesday!

-Brooks

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