-
Notifications
You must be signed in to change notification settings - Fork 0
/
technical_prep.rb
70 lines (57 loc) · 942 Bytes
/
technical_prep.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
68
69
=begin
(1..25).each do |x|
if x % 2 == 0
puts x
end
end
How do I make this into one line?
=end
color_ary = ["red", "blue", "green", "cyan"]
if color_ary.include?("red")
puts "this array has my favorite color"
else
puts "ah man, this array doesn't have my fav color"
end
greeting = "hello"
name = "Chris"
if greeting == "hello" && name == "Chris"
puts "#{greeting} #{name}"
else
puts "Who is this?"
end
score = 91
result = case score
when 0..60
"F"
when 61..70
"D"
when 71..80
"C"
when 81..90
"B"
when 91..100
"A"
else "Invalid Score"
end
puts result
fav_command = "ls"
case fav_command
when "cd"
puts "cd - Change Directory"
when "rm"
puts "rm - Remove Directory"
when "ls"
puts "ls - List Directory"
else "I don't know that command"
end
(1..100).each do |x|
if x % 3 == 0 && x % 5 == 0
puts "FizzBuzz"
elsif x % 3 == 0
puts "Buzz"
elsif x % 5 == 0
puts "Fizz"
else
puts x
end
end