The hardest part of any coding problem is looking at the mountainous problem and trying to get to the top. The only way is to break it up into as small of chunks as you can and just work through those one by one. Also, make sure you let all your thoughts flow out and type them in as comments as you work on it. Even if your thoughts are "wtf is going on with this string why is it returning a fcking array where it should be a string this is impossible oh maybe if i just have it console log A here then i can see what the previous function is passing idk man fcuck!"
as long as you open your internal dialogue to flow out into tge code you will work through it and then if you take a break and come back to it you wont lose your place or thought process at all.