Back in the day, I used to have this habit of declaring all of my variables at the top of the file. My thinking at the time was it would keep everything organised so if I needed to jump to one I’d know where to go looking.
While that might sound like a sensible approach I’ve recently learnt there are quite a few shortcomings of doing this. The main one being the larger the project gets the more difficult it is to debug problems. Jumping about the file all the time just adds to the dreaded mental load, and that reduces your problem-solving skills.
Instead, try putting your variables close to where they’re used. It will reduce your variable hunting and in the rare situations you can’t find something, remember you can just use search.