-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirectory_typos
51 lines (47 loc) · 1.97 KB
/
directory_typos
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def input_students
puts "Please enter the names of the students"
puts "To finish, just hit return twice"
# Create an empty array, array uses square brackets, not curly!
students = []
# Get the first name. Remove the extra space after gets
name = gets.chomp
# While the name is not empty, repeat this code. Forgot ! to change to not empty. Change when to while. Add ? after empty
while !name.empty? do
# Add the student hash to the array. Remove extra colon after cohort and before november. Double arrows as it is a shovel operator
# Colon comes after name and cohort as the colon symbols act as hash rockets in the key value pair, where the value is a symbol
students << {name: name, cohort: :november}
# Students count as method name is a plural
puts "Now we have #{students.count} students"
# Get another name from the user. gets, not get
name = gets.chomp
end
# return the array of students
students
end
# Change hyphen in print-header to _
def print_header
# Change put below to puts. Change single quotation and `` to double quotation marks
puts "The students of my cohort at Makers Academy"
puts "-------------"
end
# Change /student/ to |
def print(students)
# Add if else loop to check to user input, if user doesn't add a student name, it will not print an empty list
if students.include?(input_students)
students.each do |student|
# Change single quoation marks to double. Brackets after # should be curly brackets, not square, and array variables should be in square brackets
puts "#{student[:name]} (#{student[:cohort]} cohort)"
end
end
end
# Names argument should be in round brackets
def print_footer(names)
# Hash before input names.count as it is string interpolation. Change prints to puts
puts "Overall, we have #{names.count} great students"
end
# Change hyphen in input-students to _
students = input_students
print_header
# students should be in round brackets as it is an argument
print(students)
print_footer(students)