This todo will get you flexing your array and hash muscles. To start, create a file called arrays-hashes.rb
in terminal. You will code your solutions inside this file.
-
Create an array that contains strings of all of your favorite snacks. Store this array in a variable.
-
Iterate over your array of snacks to print out: "#{snack} is one of my favorite snacks."
-
Return the number of items in the array.
-
Return the first item in the array.
-
Return the last item in the array.
- Create a hash that describes your house. Store data relating to the number of bedrooms, number of bathrooms, type of house (apartment, condo, townhouse, house, etc), and size of house in square feet. Store your hash in a variable. For example, your hash could start:
house_hash={
:bedrooms => 2,
:bathrooms => 1
}
-
Iterate over your house hash to print out the key value pairs.
-
Return the number of bathrooms in the house.
-
Iterate over the house hash to print out all the values of the hash.