Complete the code to check if the number is even using a predicate method.
number = 4 puts number.[1]
odd? instead of even?The even? method returns true if the number is even.
Complete the code to check if the string is empty using a predicate method.
text = "" puts text.[1]
nil? which checks for nil, not empty stringblank? which is not a standard Ruby methodThe empty? method returns true if the string has no characters.
Fix the error in the code to check if the array includes the number 5 using a predicate method.
numbers = [1, 2, 3, 4, 5] puts numbers.[1](5)
include without the question markincludes? or contains?The correct predicate method to check if an array contains an element is include?.
Fill both blanks to create a hash with keys as words and values as booleans indicating if the word starts with 'a'.
words = ["apple", "banana", "avocado"] result = words.map { |word| [word, word.[1]('a') && word.[2]('a')] }.to_h puts result
include? which checks anywhere in the string, not just the startThe start_with? method checks if a string begins with the given prefix.
Fill the blanks to filter an array of strings to only those that end with 'ing' and check if each is lowercase.
words = ["running", "Jumping", "walking", "Talk"] filtered = words.select { |word| word.[1]('ing') } result = filtered.map { |word| word.[2] == word } puts result
downcase?downcase result to the original wordend_with? checks if the string ends with 'ing'. Then word.downcase == word checks if the word is already lowercase.