forked from turingschool/methods_cfu_am0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
final_practice.rb
67 lines (45 loc) · 1.38 KB
/
final_practice.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Defining Our Own Methods
# 1: Write a method named greeting that prints out a general greeting to someone
def greeting
return 'Hi, Friend!'
end
p greeting
# What is the return value of your method?
# 'Hi, Friend!'
# How many arguments did you pass your method?
# no arguments
#2: Write a method named custom_greeting that prints out a greeting WITH a specific name.
def custom_greeting(name)
return "Hi, #{name}!"
end
p custom_greeting("Kaylah")
# What is the return value of your method?
# "Hi, Kaylah"
# How many arguments did you pass your method?
# 1
# What data type was your argument(s)?
# String
#3: Write a method named square that takes in one number, and returns the square
# of that number
def square(num)
return num * num
end
p square(12)
# What is the return value of your method?
# 144
# How many arguments did you pass your method?
# 1
# What data type was your argument(s)?
# integer but can work for float
#4: Write a method named greet_person that takes in 3 strings, a first, middle,
# and last name, and print outs the sentence of the entire string
def greet_person(first, middle, last)
return "Hi, #{first} #{middle} #{last}"
end
p greet_person("Kaylah", "Rose", 'Mitchell')
# What is the return value of your method?
# 'Hi, Kaylah Rose Mitchell'
# How many arguments did you pass your method?
# 3 arguments
# What data type was your argument(s)?
# all strings