Rubber Duck Debugging
I don't know about you, but I have often worked out the solution to a problem with a project while trying to explain it to someone else. Just the process of laying out the problem clearly to someone who doesn't know my code often unlocks things I hadn't considered before.
This is something many developers experience, and someone coined the term "Rubber Ducking" as a method of debugging their code by explaining it to a rubber duck that was sitting on their desk.
Though you may feel like you have gone quackers, it is really a worthwhile thing to try when your code isn't making sense and you don't know why.
If you find talking to an inanimate object too difficult, then I also find it helpful to write an email to a coding buddy, or writing a detailed question on Slack laying out my problem often results in an answer coming to me... or at least a good question to Google.