tasks with specific task detailsurgent_threshold to define urgencyany? to check if any task is urgentall? to check if all tasks are completednone? to check if no tasks are overduetasks with specific task detailsurgent_threshold to define urgencyany? to check if any task is urgentall? to check if all tasks are completednone? to check if no tasks are overduetasks with these exact hashes: {name: 'Laundry', completed: false, days_overdue: 0}, {name: 'Homework', completed: true, days_overdue: 2}, {name: 'Grocery Shopping', completed: false, days_overdue: 5}Use square brackets [] to create an array and curly braces {} for each task hash.
urgent_threshold and set it to 3 to define how many days overdue makes a task urgentJust assign the number 3 to the variable urgent_threshold.
any? on tasks to check if any task's days_overdue is greater than urgent_threshold and save it in any_urgent. Use all? to check if all tasks are completed and save it in all_completed. Use none? to check if no tasks have days_overdue greater than 0 and save it in none_overdue.Use blocks with any?, all?, and none? to check the conditions on each task.
any_urgent, all_completed, and none_overdue each on its own line using puts.Use puts to print each variable on its own line.
Which Ruby method returns true if at least one element in a collection meets a condition?
any?any? returns true if at least one element satisfies the condition.all? requires all elements to satisfy, none? requires none to satisfy, and each? is not a Ruby predicate method.Which of the following is the correct syntax to check if all elements in an array are even numbers?
numbers = [2, 4, 6, 8]
# Choose the correct line below
all?.{ |n| n.even? } correctly tests if each number is even.What is the output of the following Ruby code?
words = ["apple", "banana", "cherry"]
result = words.none? { |w| w.length > 6 }
puts result
none? returns true. But "banana" and "cherry" have length exactly 6, not greater than 6.none? returns true.Identify the error in this Ruby code snippet:
numbers = [1, 3, 5, 7]
puts numbers.all? { |n| n % 2 == 0 }
What is the output and why?
n % 2 == 0).all? returns false.You have a list of user ages: ages = [12, 17, 20, 25, 30]. You want to check if none of the users are under 18 years old. Which Ruby code correctly performs this check?
none? returns true if no elements satisfy the block condition.{ |age| age < 18 } checks if age is under 18.Pass the test and this pattern moves unknown