- Make a guess before testing your answer.
- "Error out" is a valid answer choice.
- Also include a sentence on why you chose your answer.
2 ** 3
Your answer.
((16 / 4) * (2 + 1)) ** 2
Your answer.
("a milli " + "a milli") * 3
Your answer.
("a milli " * 4) / 2
Your answer.
my_favorite_number = 13
puts "My favorite number is: " + my_favorite_number
Your answer.
my_favorite_number = 13
puts "My favorite number is: #{my_favorite_number}"
Your answer.
[ ] false
[ ] 0
[ ] ""
[ ] null
[ ] [ ] (empty array)
[ ] undefined
[ ] NaN
[ ] nil
- Make a guess before testing your answer.
- "Error out" is a valid answer choice.
- Also include a sentence on why you chose your answer.
no_name = ""
if no_name
puts "My name is: " + no_name
end
Your answer.
no_name = nil
if no_name
puts "My name is: " + no_name
end
Your answer.
age = 21
if age
puts "My age is: " + no_name
end
Your answer.
age = gets.chomp
if age
puts "My age is: " + age
end
Your answer.
Write the code for the following exercise inside of the app.rb
located in this repo. Run/test your code using ruby app.rb
in the Terminal.
Fizz-Buzz is a classic coding exercise that you can create using your knowledge of conditionals and loops. Implement code that does the following...
- Counts from 1 to 100 and prints out something for each number.
- If the number is divisible by 3, print
"Fizz"
. - If the number is divisible by 5, print
"Buzz"
. - If the number is divisible by both 3 and 5, print
"FizzBuzz"
. - If the number does not meet any of the above conditions, just print the number.
Your output should look something like this...
1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, Fizz Buzz, 16, 17, Fizz, 19, Buzz, Fizz, 22, 23, Fizz, Buzz, 26, Fizz, 28, 29, Fizz Buzz, 31, 32, Fizz, 34, Buzz, Fizz, ...
We haven't covered loops yet, so to get you started...
i = 1
while i <= 100
# Your code goes in here.
end