Complete the code to pass the block parameter correctly.
5.times do |[1]| puts [1] end
The block parameter index receives the current iteration number.
Complete the code to use block parameters to sum numbers.
sum = 0 [1, 2, 3].each do |[1]| sum += [1] end puts sum
The block parameter value represents each element in the array.
Fix the error in the block parameter to print each key and value.
{a: 1, b: 2}.each do |[1]|
puts "#{ [1][0] }: #{ [1][1] }"
endThe block parameter pair holds each key-value array from the hash.
Fill both blanks to correctly unpack key and value in the block parameters.
{x: 10, y: 20}.each do |[1], [2]|
puts "Key: #{ [1] }, Value: #{ [2] }"
endThe block parameters k and v unpack the key and value from the hash.
Fill all three blanks to create a hash with word lengths using block parameters and condition.
words = ["apple", "bee", "cat"] lengths = {} words.each do |[1]| [2] = [1].[3] lengths[[1]] = [2] if [2] > 3 end
The block parameter word receives each word from the array. len stores the length computed using the length method. The condition filters words longer than 3 characters to build the hash.