In addition to @senocular’s and @kirupa’s excellent advice, I also recommend formatting your code in VS Code. In Windows, pressing [Alt+Shift+F] works for me.
When the code is correctly formatted, it may help you more quickly see where a particular
ends and, as a result, determine why it’s not working the way you expect it to work.