Complete the code to check if any number in the array is even.
numbers = [1, 3, 5, 6, 7] result = numbers.[1]? { |n| n.even? } puts result
The any? method returns true if at least one element meets the condition.
Complete the code to check if all words in the array start with a capital letter.
words = ["Apple", "Banana", "Cherry"] result = words.[1]? { |word| word[0] == word[0].upcase } puts result
The all? method returns true only if every element meets the condition.
Fix the error in the code to check if no numbers in the array are negative.
numbers = [0, 1, 2, 3] result = numbers.[1]? { |n| n < 0 } puts result
The none? method returns true if no elements satisfy the condition.
Fill both blanks to create a hash of words and their lengths, including only words longer than 3 letters.
words = ["cat", "elephant", "dog", "lion"] lengths = { [1] => [2] for word in words if word.length > 3 } puts lengths
The hash keys are the words, and the values are their lengths using word.length.
Fill all three blanks to create a hash of uppercase words and their lengths, including only words longer than 3 letters.
words = ["cat", "elephant", "dog", "lion"] lengths = { [1] => [2] for word in words if [2] [3] 3 } puts lengths
The keys are uppercase words, values are their lengths, and the condition filters words longer than 3 letters.