Valid Braces – CodeWars Challenge

There is a challenge on codewars that asks you to check whether a string of parentheses, brackets, and curly braces is valid. A string of braces is considered valid if all braces are matched with the correct brace. I.e. “()” is valid and “[(])” is not. “(){}[]” is valid and “[({})](]” is not. Etc. I’ve been able to create some logic to check for whether or not there are the right number of opening and closing braces. ATTEMPT: But I’ve not been able to come up with a way to check for whether or not the opening brace “closes” before