I am working with two arrays:
a = [
[a, b],
[c, d],
[e, f],
[g, h]
]
b = [
[a, 4],
[1, 2],
[e, 3]
]
My challenge lies in updating the elements of array a
when they match corresponding elements in array b
. Specifically, I need to add a new value to the matched element of a
. For example, if a[0][1]
matches b[0][1]
, then a[0][1]
should be updated to [a,b,new_value]
.
If creating a new array with all values of a
is necessary, that's acceptable. However, it's crucial that the original values and order of a
remain unchanged.
Despite my attempts at utilizing various types of loops, I'm struggling to achieve the desired outcome. Any guidance or solutions provided would be greatly appreciated.
Thank you sincerely.