Whenever I’m stuck on a coding problem, my instinct is to turn to my (senior developer) partner, gesture at the screen, flail at the keyboard and say, ‘Make it work!’
Needless to say, this approach (and yes, I have tried it), does not work.
Knowing how to ask for programming help is a really tricky skill for beginners. For us musicians, we are used to individual lessons where a teacher knows us and our context very well. These teachers often tell us what we need help with and don’t leave space for us to self-direct.
So here’s a basic template (adapt as needed with experience) that you can use to ask for help.
What language and version are you using?
Where/how are you trying to run this code? (E.g. in the browser console, the command line, an interactive shell)
Which operating system (macOS, Windows, Linux) or browser if you’re running it in the browser (Chrome, Firefox, Safari etc) are you using?
What is the context? (E.g. this is a single function or it’s the final stage in a complex web app request or it’s an automated test.)
What is the expected output?
What is the actual output?
What have you tried so far to fix it? (It really helps to keep a record of this. I use a bullet journal.)
What is the critical thing you are trying to do? (E.g. select a random number, receive a 200 status response.)
Which method(s) is/are you using to achieve this thing?
Send code snippets / screenshots!
Quite often by the time you have answered all these questions, you will have solved the problem. Not all of it will be relevant to your specific problem but it’s good to know anyway! And if you haven’t solved your problem, this gives someone else really useful information to help you.
Got other questions to include? Let me know in the comments!
Have you forgotten to include a return statement?