-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathlist.rb
More file actions
34 lines (31 loc) · 953 Bytes
/
list.rb
File metadata and controls
34 lines (31 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Given this list of people, print only names of
# people who are at least 16.
#
# Yes, you could just look at it with your eyes
# and print their names, but imagine that you
# couldn't because there are a million items in the list.
#
# Use the variable, loops, and conditionals instead.
#
# Print each name on a new line, like:
#
# James
# Yolanda
# etc.
#
# (Hint: the list_of_people variable is an Array. How
# do we loop through the items in an Array?)
list_of_people = [
{ :name => "James", :age => 16 },
{ :name => "Lee", :age => 12 },
{ :name => "Yolanda", :age => 26 },
{ :name => "Mel", :age => 15 },
{ :name => "Red", :age => 38 },
{ :name => "Fatimah", :age => 31 },
{ :name => "Carl", :age => 9 },
]
# ~~~~~ Specs (make it do these things) ~~~~~
#
# list.rb prints 'James', 'Yolanda', 'Red', and 'Fatimah' using variables, loops, if statements, and Hash methods'
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~