How do I write a code that determines whether the two 2D images selected are equal to each other?

I have a 2D matching game where I have ten images that match each other (Five on the left side and five on the right side of the screen). I want to create a code that will determine whether the two images selected are correct or not. Each of the images have their own tag so for example, the image of a wallet has a tag called wallet. Can you help me understand how to write a code that does that?

probably by creating a function like this:

public bool EquateSelected(GameObject first, GameObject second){ return first.tag == second.tag; // returns true if they equal each other }