r/learnprogramming • • Aug 04 '23

Unexpected function problem.

I have a small problem that I create a project in js, css, html, which is launched locally in the browser and when everything I did last worked normally, when I launched the script the next day, one function stopped working completely and the other one works incorrectly. When I ran the script (the current version) the next day, I did not modify these functions in any way, I did not change their calling context, nor did I change other functions that affect them in any way. The console in the code editor as well as in the Chrome browser does not have a single syntax error, etc. I always make copies of the entire script so that I can restore something if I messed up in the current version, or I would like to restore something as I did in the previous version. In these older copies, these functions worked normally, nothing happened, now if I remove this current version of the code and put the old one, where these functions should work, it's the same problem. Anyone know what could have happened? I haven't changed any settings in the browser either. In this case, it can't be a problem with the code, but with something from the outside.

1 Upvotes

15 comments sorted by

View all comments

2

u/[deleted] Aug 04 '23

Don't work like this, acquire good work habits from the beginning - use Git. This way you could watch changes and history of code, compare between current and previous version and see what has changed. You could also share your code on Github with others so they can give you feedback. Hard to tell exactly without seeing the code.

1

u/Tough_Pride4428 Aug 04 '23

But since the previous version of the script worked without a problem and now it suddenly doesn't work without making any modifications to it, it means that it can't be a code problem.

1

u/[deleted] Aug 05 '23

But since the previous version of the script wor

Ok, if you are sure of your conclusion than try a different direction. Something has changed for sure because it used to work and now it doesn't, you just not sure what it was. You already said it can't be the code that has changed or a caching issue so what else could it be? Give more information and people can help you to proceed.

I don't believe anyone can help you further without seeing your code first, and good work habits are never to late to acquire so I just offered the above but of course you don't have to follow my advice :)

0

u/Tough_Pride4428 Aug 05 '23

If something changed in the code itself, I would have solved it by now. But it's 100% not the code's fault, because the problem is there all the time. I already checked all the code for everything. When I turned on the Google browser the next day, I noticed that my saved recent pages on the main search page had been deleted. Which I haven't done myself. Therefore, I'm sure something has changed in the browser, and I don't know what.

2

u/[deleted] Aug 05 '23

If something changed in the code itself, I would have solved it by now. But it's 100% not the code's fault, because the problem is there all the time...

Ok, so to tackle this and to find the root of the problem you need to try a few stuff until you find the cause. Be creative here and brainstorm. Maybe try and run it in a different browser see if the issue is reproduced there as well, try private mode, try changing things in your dev env, etc.

I can't tell you what's wrong, just trying to show you a way of maybe how to solve it yourself. Hope it helps.