Generation

generate functionSun, 13 Nov 2022

Multiply the values of a hash by the keys

def product(hash) hash.map { |k, v| k * v }.reduce(:+) end product({1 => 2, 3 => 4, 5 => 6})

Questions about programming?Chat with your personal AI assistant