Update a map that is outside scope of an iterator

map_A = Enum.reduce(map_A, %{}, fn {k, v}, out ->
if Enum.member?(Map.keys(map_B), x) == true) do
Map.put(out, k, “yes”)
else
Map.put(out, k, “no”)
end
end)

You need to remember that whatever way you do it you need to assign the output of the function to your variable.