forked from learn-co-curriculum/hs-ruby-assessment-public
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruby_review.rb
More file actions
109 lines (71 loc) · 2.62 KB
/
ruby_review.rb
File metadata and controls
109 lines (71 loc) · 2.62 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Level 1: Arrays
# This is the array that rspec will be using to call and test each of the methods below: teachers = ["Steph","Victoria","Vanessa"]
def add_name(array)
# Write code inside this add_name method to add the string "Danny" to the array
end
def print_items(array)
# Iterate over each element in the array and puts it
end
def first_item(array)
# Return the first item in the array
end
def third_item(array)
# Return the third item in the array
end
# Level 2: Hashes
# This is the hash that rspec will be using to call and test each of the methods below:
# {:name => "Danny", :age => 55}
def name(hash)
# Return the value of :name from the hash
end
def add_location(hash)
# Add a key :location to the hash with a value of "NYC"
end
def print_key_value_pairs(hash)
# Iterate over the hash and puts each key value pair. Make sure to use string interpolation and pay attention to punctuation!
end
# Level 3: Nested Data Structures
# This is the hash that rspec will be using to call and test each of the methods below:
# school = {
# :name => "Happy Funtime School",
# :location => "NYC",
# :instructors => [
# {:name=>"Steph", :subject=>"Violin" },
# {:name=>"Victoria", :subject=>"Field Hockey"},
# {:name=>"Vanessa", :subject=>"Karaoke"}
# ],
# :students => [
# {:name => "Marissa", :grade => "B"},
# {:name=>"Billy", :grade => "F"},
# {:name => "Frank", :grade => "A"},
# {:name => "Sophie", :grade => "C"}
# ]
# }
def modify_hash(nested_hash)
# Add a key :founded_in with a value of 2013.
end
def return_first_student(nested_hash)
# Return the first student in the students array
end
def add_student(nested_hash)
# Add a student to the end of the nested_hash's students array. Make sure to give the student a name and grade.
end
def add_semester(nested_hash)
# Iterate through the students array and add a key :semester to every student with the value of "Summer".
end
def find_student_by_grade(nested_hash)
# Use the .find method (it works similar to .each) to iterate through the students array and look for a student with :grade == "B".
end
def find_student_by_name(nested_hash)
# Use the .find method to look for the student named "Frank. This time return only Frank's grade (not all of his info.)
end
def change_frank_grade(nested_hash)
# Use the .find method to find "Frank" and change his grade from "A" to "F".
end
def delete_student(nested_hash)
# Delete the student named "Billy" from the hash
end
# Bonus!
def print_all_items(nested_hash)
# Write out the code to puts all the values in the school. NOTE: If this takes too long, skip it!
end