Created
June 10, 2013 20:06
-
-
Save surrealdetective/5751802 to your computer and use it in GitHub Desktop.
arrays
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
# Construct an array with your favorite foods. It should have at least 5 elements. | |
# Write a puts which returns your most favorite food out of the array. | |
fav_foods = ['lasagna', 'salmon', 'avocado', 'grapefruit', 'milkshake'] | |
puts fav_foods[1] | |
# Construct an array with the colors of the rainbow (ROYGBIV) | |
# Slice the colors Red, Orange, and Yellow out of the array. | |
colors = ['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Indigo', 'Violet'] | |
colors.slice(3, 6) | |
# Create an empty array. | |
# Assign values to the the second and 6th position. | |
test_array = [] | |
test_array[1] = 'This is the 2nd position.' | |
test_array[5] = 'This is the 6th position.' | |
test_array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment