Take a break and remind yourself why you want to do it. Or why you started. Visualize your goal. Visualize how you feel in the future and what possibilites you will have if you keep going.
That always works for me :) But we are all different.
I also wrote an article about coding motivation ;) hashnode.com/post/-why-you-should-keep-coding--cj…