Best way to find if string is in an array of strings

I have 2 arrays of compound identified by a string (enchantements on a book and enchantements on a sword for example) and I want to paste the enchantments of the book onto the sword, without creating duplicate of enchantments and if enchantments is already here, update level of enchantments. What would be the simplest way of achieving this ? I'm on 1.17 by the way.

Continue to help post