Last active
February 17, 2016 16:16
-
-
Save verner-dz/1ef936034c4d6dc6c727 to your computer and use it in GitHub Desktop.
Week 2 Bonus HW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HW Question | |
Part 1 | |
Write a method that can allow a user to enter as many stories as they want. | |
Each story has a headline and upvotes. | |
Ask the user to enter the headlines and upvotes as many times as they requested. | |
Part 2 | |
Store each of those stories in a seperate hash. So if a user said they wanted to | |
enter 3 stories, there must be 3 hashes. | |
Then store all those hashes in an array. | |
Show all the headlines and upvotes in that array in this format: | |
"Headline is: "Man loves Cat". This story has 6 votes." | |
"Headline is: "Woman loves Dog". This story has 8 votes." | |
"Headline is: "Baby loves Tedy Bear". This story has 10 votes." | |
Part 3 - Bonus(extra reading required) | |
Now that you have all those hashes in the array, I want you to iterate through them and | |
show them in the format below, only this time you're iterating through the array | |
and not doing stories[0][:headline] as you did in Step 2. | |
"This is story number 1. Headline is: "Man loves Cat". This story has 6 votes" | |
"This is story number 2. Headline is: "Woman loves Dog". This story has 8 votes" | |
"This is story number 3. Headline is: "Baby loves Tedy Bear". This story has 10 votes" | |
*** By the way guys we did not learn how to iterate through arrays in class, but I | |
wanted to give you all a headstart. Here's some reading material to help you | |
with the bonus section: http://blog.teamtreehouse.com/ruby-arrays | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment