forked from turingschool/backend_mod_1_prework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathannotations.rb
48 lines (44 loc) · 1.58 KB
/
annotations.rb
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
# Add your annotations, line by line, to the code below using code comments.
# Try to focus on using correct technical vocabulary.
# Use the # to create a new comment
# Build a Bear
# making a new method called build_a_bear
def build_a_bear(name, age, fur, clothes, special_power)
# establishing variables below: different from arguments in line 7
greeting = "Hey partner! My name is #{name} - will you be my friend?!"
demographics = [name, age]
power_saying = "Did you know that I can #{special_power}?"
built_bear = {
# attributes of the bear
'basic_info' => demographics,
'clothes' => clothes,
'exterior' => fur,
'cost' => 49.99,
'sayings' => [greeting, power_saying, "Goodnight my friend!"],
'is_cuddly' => true,
}
return built_bear
end
# making 2 different instances of the bear
build_a_bear('Fluffy', 4, 'brown', ['pants', 'jorts', 'tanktop'], 'give you nightmares')
build_a_bear('Sleepy', 2, 'purple', ['pajamas', 'sleeping cap'], 'sleeping in')
# FizzBuzz
# method fizzbuzz
def fizzbuzz(num_1, num_2, range)
#in line below: It goes through each element of the 3 arguments and from there it decides whether or not to pit fizzbuzz, fizz, or buzz depending on the constraints given
(1..range).each do |i|
if i % num_1 === 0 && i % num_2 === 0
puts 'fizzbuzz'
# use the elsif after the 'if'
elsif i % num_1 === 0
puts 'fizz'
elsif i % num_2 === 0
puts 'buzz'
# in the last one, use 'else' if does not satisfy any of the conditionals sent prior
else
puts i
end
end
end
fizzbuzz(3, 5, 100)
fizzbuzz(5, 8, 400)