Getting lost in complexity/order of ejecution. Don´t know what to do...!

For me, at least, I want to dive in and code, and in doing so, I frequently miss something critical to actually making it work. It sounds like you’ve got a similar mindset. So, you’re probably going to be frustrated with my answer below, but know it comes from personal experience and genuinely wanting to help you.

First

When my code has such poor variable naming, inconsistent spacing, and hacky code (e.g. 1==1) as what you’ve posted, it’s a huge red flag that I really need to take a big step back, walk away for a bit (an hour to a couple of days is normal for me), and then —when my brain has let go of the current approach, or I realize I hadn’t accounted for x— then I know it’s time to revisit the problem.

And yes, I sometimes have to do that multiple times for the same problem.

Second

For many reasons, you should provide a fully replicable version of your code.

When I come here to help others, I benefit from having all the code. For example, I can assume what you’ve set fromthere, toReturn, etc to, but I can’t verify it.

I also can’t run your code to replicate your results or tweak your code.

And as someone trying to help, I personally try to provide explanatory comments inline and/or working examples that start from your actual code (e.g. 0, 1 2, 3, 4) but if you don’t provide all of your code, ideally in an easily editable and sharable format (e.g. https://repl.it, https://codepen.io/, https://jsbin.com/, https://jsfiddle.net/, http://plnkr.co/, https://codesandbox.io, etc.) then I simply can’t help you that way.

Third

I’ve also learned that poor variable names, poor spacing, hacks, etc. make it hard for other people to read my code, and therefore they’re less likely to look at my code, and therefore they’re less likely to give me meaningful feedback.

As a result, I make a point to clean up my code before posting it with a request for help.

Obviously, this makes it more likely that I’ll get help, but it frequently helps me actually understand the problem in a different way and I solve the problem on my own, or it helps me find silly typos and again I solve the problem on my own.


So, I strongly suggest, that you (a) refactor your code with variable names that would make sense to a friend or family member who doesn’t know how to code, (b) clean up your indentions, © add pseudo-code comments explaining different branches of logic, and (d) then repost your request for help.

1 Like