-
Notifications
You must be signed in to change notification settings - Fork 0
/
if_else.rb
35 lines (29 loc) · 851 Bytes
/
if_else.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
#if/else statements!
#1. write a simple math equation
if 2 + 2 == 4
puts "2 + 2 does indeed equal 4"
end
#2. Use a string for your if statement
my_name = "Shana"
if my_name == "Skillcrush"
puts "Hellooooooo, #{my_name}!"
else
puts "Oops, I thought your name was Skillcrush. Sorry about that, #{my_name}!"
end
# favorite color
fav_color = 'yellow'
if (fav_color == 'red')
puts "Red like fire!"
elsif (fav_color == 'orange')
puts "Orange like, well... an orange."
elsif (fav_color == 'yellow')
puts "Yellow daffodils are so pretty in the spring!"
elsif (fav_color == 'green')
puts "Have you been to the Emerald City in Oz?"
elsif (fav_color == 'blue')
puts "Blue like the sky?!"
elsif (fav_color == 'purple')
puts "Purple plums are the tastiest!"
else
puts "Hmm... well I don't know what color that is!"
end