Skip to content

Instantly share code, notes, and snippets.

@RJGrunau
Last active February 1, 2020 22:56
Show Gist options
  • Save RJGrunau/990807998e90b4bb5db2baff75754ce8 to your computer and use it in GitHub Desktop.
Save RJGrunau/990807998e90b4bb5db2baff75754ce8 to your computer and use it in GitHub Desktop.
Ruby practice while taking a Udemy rails course.
def name_anaylzer (first_name, last_name)
full_name = "#{first_name} #{last_name}"
reversed_full_name = full_name.reverse
name_length = first_name.length + last_name.length
if first_name.empty? && last_name.empty?
p "You need to enter your first and last name"
elsif first_name.empty? then
p "You need to enter your first name"
elsif last_name.empty? then
p "You need to enter your last name"
end
if !first_name.empty? && !last_name.empty?
p "Your full name is #{full_name}"
p "YOur full name reversed is #{reversed_full_name}"
p "Your name has #{name_length} characters in it"
end
end
p "What is your first name?"
user_first_name = gets.chomp
p "What is your last name?"
user_last_name = gets.chomp
name_anaylzer(user_first_name, user_last_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment