Skip to content

Instantly share code, notes, and snippets.

@richcsmith
Last active August 29, 2015 14:02
Show Gist options
  • Save richcsmith/90aa98593ec3741ba7db to your computer and use it in GitHub Desktop.
Save richcsmith/90aa98593ec3741ba7db to your computer and use it in GitHub Desktop.
=begin
Instructions
============
1. Copy the code here: http://bit.ly/SLB5Ah
2. Fix it.
3. Make up your own city names using an array called 'cities'.
4. Print the length of the characters of each person's name.
5. Ask the user for their name and where they are from.
6. Your final output should look like the following:
What's your name?
richard
Thanks Richard, and where are you from?
new jersey
Thanks - here's some info about you and some of my friends:
Your name is Richard, you're from New Jersey, and your name is 7 characters long.
Sarah is from London and their name is 5 characters long.
John is from New York and their name is 4 characters long.
Melanie is from San Francisco and their name is 7 characters long.
Bryan is from Dublin and their name is 5 characters long.
Amy is from Miami and their name is 3 characters long.
Justin is from Chicago and their name is 6 characters long.
There are 7 people in total, including you.
Hints
=====
Use the .capitalize method to capitalize the first letter of a word
Example: "rich".capitalize -or- variable.capitalize
Use the .length method to find the length of strings, arrays, etc.
Feel free to ask me anything if you get stuck.
Good luck!
=end
names = [sarah, john, melanie, bryan, amy, justin]
num_people = 0
loop_num =
puts "Hi there, what's your name?"
puts "Thanks, and where are you from?"
num_people = num_people + 1
puts ""
puts "Thanks - here's some info about you and some of my friends:"
names each name
name = .capitalize
city = cities[loop_num].capitalize
puts "#{name} is from #{city} and their name is characters long."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment