Complete the code to print a greeting message.
puts [1]In Ruby, puts prints the string to the screen. The string must be in quotes.
Complete the code to define a method that returns true if a number is even.
def even_number?(num) num.[1] end
odd? instead of even?.is_even.The Ruby method even? returns true if the number is even.
Fix the error in the test code to check if 5 is odd using RSpec.
RSpec.describe 'Number' do it 'checks if 5 is odd' do expect(5.[1]).to be true end end
even? which returns false for 5.is_odd.In RSpec, to check if 5 is odd, use the Ruby method odd?.
Fill both blanks to create a hash of word lengths for words longer than 3 letters.
lengths = {}
for word in words
if word.[2] 3
lengths[word] = word.[1]
end
endlength? which is not a Ruby method.Use word.size to get the length of the word and compare it with 3 using >.
Fill all three blanks to create a hash of uppercase words and their lengths for words longer than 4 letters.
result = {}
for word in words
if word.length [3] 4
result[[1]] = [2]
end
endword.downcase instead of uppercase.Use word.upcase as the key, word.length as the value, and check if length is greater than 4 with >.
