We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7cdebda commit c4c5869Copy full SHA for c4c5869
bin/birthday_helper.rb
@@ -5,18 +5,20 @@
5
path_to_csv = './bin/birthday_data.csv'
6
end
7
8
-puts "Please type a name"
9
-name = gets.chomp
+
10
11
spreadsheet = CSV.read(path_to_csv, headers:true)
+place = nil
12
13
-for x in 0...spreadsheet.length
14
- if spreadsheet[x][0] == name || spreadsheet[x][1] == name || "#{spreadsheet[x][1]} #{spreadsheet[x][0]}" == name
15
- place = x
+puts "Please type a name"
+name = gets.chomp
+spreadsheet.each do |row|
16
+ if row["first_name"] == name || row["last_name"] == name || "#{row["first_name"]} #{row["last_name"]}" == name
17
+ place =row
18
19
20
-birthday = spreadsheet[place][2].split('/')
21
+birthday = place[2].split('/')
22
age = 2014 - Integer(birthday[0])
23
24
if birthday[1] == "01"
0 commit comments