Could someone explain why this works but returning inside the if(cursor.mark !== undefined) fails?
And also why it fails when you put var res inside the function scope?
Because I can't see for the life of me how that changes any functionality.
(My first try was very similar as this except with immediate return etc. and I couldn't(/can't) figure out at all why it doesn't work.)
...
Could someone explain why this works but returning inside the if(cursor.mark !== undefined) fails?
And also why it fails when you put var res inside the function scope?
Because I can't see for the life of me how that changes any functionality.
(My first try was very similar as this except with immediate return etc. and I couldn't(/can't) figure out at all why it doesn't work.)
fixed that
This comment is hidden because it contains spoiler information about the solution
cool!