r/webdev • • 1d ago

Question Finding it impossible to solve problems

Hey guys. I'm a web developer and have a job but unsure if I can pass future interviews, because when I get a technical question like a basic loop problem, "program that starts counting from 1 and increases by 1 during each iteration, stopping once it reaches 5". This is incredibly incompetent and concerning, not to mention AI has made me worse.

What's the solution to this? I can memorize solutions but what happens when a new problem comes up in an interview and I can't remember the syntax even if I know I need a loop or some thing else to solve a problem? I feel like crying

28 Upvotes

91 comments sorted by

79

u/bcons-php-Console 1d ago

The example you give is very basic, it seems that you lack knowledge of the basics of programming.

Look for a JS course that starts with the basics (I've heard many people praise Wes Bos' "Beginner Javascript" course) and spend at least half an hour every day. Just like learning a new language or getting in shape, constancy here is key.

As you progress your confidence on solving problems will build up. Good luck!

PS: just curious, what's your current web dev role?

7

u/Shahadat__ 1d ago

Thanks for the encouragement. I did go through wes bos, as well as javascript. info, coding along. Then when it comes time to actually solve a problem with what I've learned, I'm lost.

My current role is Shopify dev. I'm 21 years old.

23

u/LoudBoulder 1d ago

This sounds to me like you're just new. Another thing that comes with experience is the ability to break a problem up into sensible and managable chunks. A lot of new programmers get overwhelmed when faced with problem X because it needs a lot of moving parts to complete. Try to lock in to one thing at a time instead of trying to solve the entire problem at once.

8

u/pb__ 1d ago edited 1d ago

Unfortunately there's a very steep slope between watching a tutorial coding along and actually applying that knowledge at work. Watching more tutorials won't be much help, either (google "tutorial hell"). Try to make a new project from scratch using what you learnt (and the documentation), only referring to google/stackoverflow (but *not* AI) when you're really stuck on something. You'll get better over time.

It's best to make some app that you would find useful, for example a personal todo-list, but if you struggle to come up with any idea, you can use this list for example: https://github.com/florinpop17/app-ideas - it's good, because every idea has specific requirements and user stories, so you know what exactly to achieve.

7

u/0dev0100 1d ago

Gotta do some problem solving without the tutorials or references open.

You can open the docs/tutorials after a while as long as it's not immediately 

11

u/Wartz 1d ago

Op is likely a troll

9

u/eyebrows360 1d ago

Or just an idiot. Not everyone seeking help is some savant-in-waiting that just needs a little nudge.

6

u/Wartz 1d ago

One can be both at the same time.

4

u/Shahadat__ 1d ago

Wish I was

3

u/saltyourhash 1d ago

Wes' stuff is great, did you take his advice and tweak the projects so you are forced to learn the concept, not just follow the step-by-step guide? and did you practice after by combining different concepts? That's key to really having the stuff sink in. It takes practice and experience.

4

u/winky9827 1d ago

Stop doing the course/tutorials. Find one that teaches you basic concepts. You're likely memorizing course material without gaining the fundamental knowledge backing the code. The example you gave, a basic for loop, is something even a 90 year old programmer will be able to rattle off the top of his head. I don't know if you're exaggerating, but if not, you definitely need to hit the brakes and start with the fundamentals.

27

u/thekwoka 1d ago

"program that starts counting from 1 and increases by 1 during each iteration, stopping once it reaches 5"

I hate to say it bruv, but you were never a developer...

5

u/saltyourhash 1d ago edited 1d ago

Honest answer that needs to be said. I could teach this to my wife in an afternoon, she'd need to practice syntax, but conceptually, it's there.

That being said, I have gotten tied up on the dumbest stuff due to being stresses out in an interview. My two favorites were:

  • writing a "memory-less" stopwatch in TDD: I was interviewing for the fornt and lead for the intuit turbo tax team, the two snarky engineer interviewers were so condescending in how they interacted I spent more time panick brainstorming a way to politely decline finishing the interview while I stare blankly at my pseudo code on a white board. I got there in the end, solved it via TDD, wrote the pedudo code for the tests. They said I did well, but they just ghosted me. The job was using Handlebars.js, so, I took the unorthodox approach of being bold and I built an entire todo application in handlebars to show I knew the language, they didn't even look at it.

  • iterating over 100 cats, adding a hat to each cat via a loop where the loop increments the step count by one each iteration : I was interviewing for AppAcademy, I thought it'd be such an amazing opportunity and I was desparate. I had spent all night panicked about the interview. It was an application for their ruby on rails program. I'd even gone up to SF the weeks prior to check the place out. In hindsight it was actually super sketchy, there were students who couldn't afford housing in the city just calling out in the office with sleeping bags. That's not the only time I've heard of that at bootcamps, though. Anyhow, I spent so much time panicking when I had the interview I LITERALLY FORGOT HOW TO WRITE RUBY... I was doing RoR the last year or so, even on a paid client project. I panicked and did the entire interview in PHP, lol.

34

u/Spaceless8 1d ago

There's no way this is real, right?

10

u/horizon_games 1d ago

Some of these comments too are just the lowest bar, as if forgetting absolute basics are okay

2

u/d9jj49f 1d ago

Didn't forget, just didn't learn to begin with. You can barf out a WordPress site and call yourself a "web developer". 

2

u/saltyourhash 1d ago

I remember years ago, the first time I ever built a wordpress site, I had to build a custom twitter feed plugin, lol.

9

u/Ansible32 1d ago

hey chat I am a physicist but I just can't follow like F=ma like what is m again? I'm worried I won't be able to get a job.

2

u/saltyourhash 1d ago

I think it stands for "your Mom"?

2

u/Shahadat__ 1d ago

its real and I'm scared

15

u/activematrix99 1d ago

Maybe programming isn't for you.

-1

u/Shahadat__ 1d ago

assuming thats true, what are my options in tech? DevOps? I've self hosted software using docker, coolify, hosted things on a raspberry pi. Are there paths for me that are not focused on programming? Im 21 and want to do this while I have my current job

10

u/activematrix99 1d ago

There are thousands of tech jobs that do not involve programming. Most of them, actually.

1

u/Shahadat__ 1d ago

Can you name some? I know I can google it of course but I've done enough of that

5

u/ParkingAthlete119 1d ago

Product, Support, IT, Sales, Scrum/Agile, Manual/UAT QA, UX, Cybersec, Marketing, Social Media, HR, etc

2

u/InDaBauhaus 23h ago

i love how in cybersec you can barely know any programming for some jobs, but you can also be the programming god, who knows their stack from keystrokes of writing code to transistors performing operations on bimodal "non-binary" continuum of voltage, for you to be of any use

1

u/ParkingAthlete119 21h ago

There's app sec/sec eng/vuln research/malware dev but they're all pretty small in the grand scheme of things when accounting for SOC, GRC, CISO, Pen Test, Ops, Cloud type work

1

u/CuteKiwi3395 20h ago

Damn dude if you can’t even google then any job in IT ain’t for you. You’re just so used to everything being handed to you that you’re not able to comprehend the bigger picture.

0

u/Shahadat__ 19h ago

I've done all that bruh I just wanted to talk to a real person about it

1

u/ForsakenCampaigns 20h ago

Do ui/ux , better connections within the company which means easy advancement. Devs are kept in a black box and can also advance

2

u/thekwoka 1d ago

documentation writer

1

u/Valent-in 1d ago

Do you mean writing those jsdoc annotations?

5

u/mekmookbro Laravel Enjoyer ♞ 1d ago

I can memorize solutions but what happens when a new problem comes up in an interview and I can't remember the syntax even if I know I need a loop or some thing else to solve a problem?

I've been there, and what worked for me was just doing it. Figure out the solution, but don't memorize it, learn how it's solved. Try to see the logic behind each line of code that answers the problem. You can use a you-know-what to help you with that, but I'd use it as a last resort because figuring something out yourself helps you understand the concept and the logic much better

And when a new problem comes up, do the same. Especially if you're aiming for backend development, it's not all querying the database and printing the html. Designing complex algorithms, figuring out optimized ways to do the same thing is also a part of the job, and there's no easy way.

Think about all the things you currently know, you didn't learn them in a few minutes. It takes time to learn something, and it takes practice to internalize that knowledge and to know when you need to use that particular approach.

I've been a backend developer for 15 years and I'm still learning something new every day about my field.

3

u/Shahadat__ 1d ago

Think about all the things you currently know, you didn't learn them in a few minutes. It takes time to learn something, and it takes practice to internalize that knowledge and to know when you need to use that particular approach.

you're right, thank you. I was just panicking without properly practicing like I should

9

u/No_Record_60 1d ago

Solve it from human perspective first. Then teach the computer how to do it.

Don't think about syntax or program at first. Just focus on solving the problem

3

u/Lachtheblock 1d ago

I think you need to ask yourself the question what you enjoy doing? Do you enjoy programming? Is it design you care about? Do you enjoy solving these problems or is it just a job for you?

2

u/Shahadat__ 1d ago

I do enjoy it if I can solve a problem by myself in rare occasions, even though to me it is just a job. If I could solve those problems interviewers throw at me or ones in advent of code or leetcode for example, I would enjoy being able to solve. Right now my mind just comes to a blank when faced with a problem in most cases, I don't know what to write to solve the problem

2

u/Lachtheblock 1d ago

I guess I'm just confused as to what your hang up is. If you enjoy solving problems, start with easier ones and go from there. Like any skill it takes practice. If you enjoy it, it shouldn't feel like a chore.

1

u/NotPromKing 1d ago

It’s hard to find something much easier than the example OP gave. If OP struggles with that example…. Programming isn’t for them, full stop. No amount of practice is going to get them anywhere.

0

u/Shahadat__ 1d ago

My hang up is that I don't remember the syntax and what to write to solve a problem. If I practice 30 days of JS in leetcode, and then more practice problems elsewhere, is that all I need to do to be able to solve other problems I might encounter (such as advent of code)?

2

u/LoudBoulder 1d ago

I dunno I started programming/solving problems when I was 14 and I still feel like I benefit from just doing hobby projects etc and I've put down thousands of hours over the last 29 years. To only see it as a job and hope to get proficient in a month.. I dunno. If my heart wasn't truly in this I couldn't see myself doing it.

1

u/Shahadat__ 1d ago

It doesn't have to be a month. I can take a year. I don't have other options at present beyond programming

3

u/Maxion 1d ago

I mean honestly dude it sounds like programming just isn't for you.

There's no cheat code to this. You just do.

2

u/wasdninja 1d ago

No offense but what did you practice? If you can't write a loop after a months practice programming genuinely might not be for you.

1

u/eyebrows360 1d ago

(such as advent of code)

... what's your native language?

2

u/thekwoka 1d ago

It's mostly a logic and reasoning thing, not a code thing...

3

u/Full_Tooth_a 15h ago

I think two separate problems are getting mixed together: understanding the logic and remembering JavaScript syntax. For the loop, put the steps in plain English: "Start at 1, show the number, add 1, and stop after 5." If that makes sense, you understand the logic. You can look up the syntax in the docs. I'd spend 15 minutes working without AI on small variations, such as counting backward or counting by twos, then rewrite the solution in a blank file. That should make the actual sticking point clearer instead of reinforcing the memorization loop.

5

u/TheRNGuy 1d ago edited 1d ago

Google and learn.

Use step debugger with logging if you don't want to use ai.

If you use functions and patterns a lot, you'll remember them (be aware done may be bad style or anti-patterns; learn those so you don't use them)

2

u/Schlickeysen 1d ago

What programming language are you talking about?

1

u/Shahadat__ 1d ago

Javascript
I experience the same in other languages, like Python

-5

u/Schlickeysen 1d ago

Let's start with the easiest to read: Python.

# Python 3
#
# The easiest of all. 3 lines of pretty boring code, and that's it.
# That's what we love Python for.
#
# I moved the logic into a function, but you can also just use a simple
# .py file and then run "python3 counter.py" in your CLI.
#
# "def" is the keyword here to create a function. Since we have nothing
# that we want to use within this function that comes from outside
# (remember, we still have to call/start it; it doesn't run alone) the function,
# we don't give it any arguments, so empty braces.
#
# Then the heart of the function: the loop. You said, "Start counting from one
# and increase by 1, and stop after hitting 5".
#
# The "for" starts the loop, almost in human language. Look closely:
#
# for <this is a placeholder for the current number> in range(<start number>, <end number>)
#
# Last task: showing it in a terminal. Here, we'll use `print(...)`, which tries
# to put everything within its braces into something readable. Our numbers
# are readable, since they're just... numbers.
#
# Inside that function call (the `print(...)`), we will use a placeholder.
# Why? Because in every round, it's a new number. And `number` is the one
# that has it.
#
# To make Python know we're using actual Python variables inside what should be a string
# (obvious, right?), we use:
#
# f"..."
#
# Any variable we have access to, like `number`, we can enter it nicely inside the output
# by using the curly braces and then the variable name.
#
# Ah, wait, stay here! Don't forget to actually START the function. You just use the
# function's name and add braces `()`, which are empty here because we don't need them
# (but Python wants them).
#
# Save into a .py file, like "script.py", and then run it with
# python /path/to/the/script.py
#
# Now we're done!

def count_to_file():
    for number in range(1, 5):
        print(f"Current number: {number}")

count_to_file()

-1

u/Shahadat__ 1d ago

Thanks for this! So here I definitely understand this, but then how do I remember it? Do I just memorize the loop? Here you've used a function and a loop to solve a problem, when I'm faced with a problem, I struggle with 1, remembering the syntax to e.g. for number in range(1, 5) 2. what to do about other problems?

4

u/Schlickeysen 1d ago

People always think programming languages are for math wizards. But it's not. It has a lot of similarities to a natural language, like English: We have grammar (syntax), we have vocabulary (statements), ... See the similarities?

Sad news, though: Just like in English, you must memorize your vocabulary and grammar rules. But this is 100x easier than you think – but only if you use what you've just learned.

Change it, increase the numbers, throw in some examples – anything that keeps you working with new code.

Here's a little secret: The vast majority of programmers can't even memorize everything in a programming language. Well, that's no problem with Google, right? I'd stay a little bit away from AI since it's just too convenient to copy and paste what it says without reading it.

Ask Google: "how can i open a .txt file in python?" It's still AI, but more limited in explanations. This is what I got:

with open( "my_file.txt, "r" ) as file:
  content = file.read( ) print( f"This is in the file: {content}" )

# Note: This is not inside a function. We can just run the .py file.

(I added some spaces inside the braces to make it more readable)

I'm 100% sure you already see a lot of similarities. So, give yourself enough time to learn; it doesn't happen overnight. At some point, you'll write these things in seconds by hand. And then, you can think about using AI, because then you will actually know what you can do with AI and what the consequences are.

1

u/Shahadat__ 1d ago

Thanks man. This helps. I'll just do whats obvious as you're saying, practice however I can. I'll give myself a year

2

u/LoudBoulder 1d ago

Do you use an editor that has syntax highlighting/completion?

If you do then it's just about repeat practice like everything else.

1

u/Shahadat__ 1d ago

Yeah vscode
How do you recommend practicing? Should I go to things like 30days of js in leetcode, advent of code etc and keep trying those?

2

u/LoudBoulder 1d ago

I feel it's good practice to just make stuff. Start very simple (its a reason a todo list often is referred to as a first project). Then do it again, maybe in another language, with another code structure. Each time I wanted to improve upon the last project. So cleaner code, clearer code structure, better testing, etc etc.

But my path may be severely out dated these days. I just know if I was hiring I would not consider someone who struggled to remember basic syntax and relied on stints of leet code or similar to try to get up to speed. Becoming proficient in this takes a lot of time, and I sure don't want all that time to be company time.

1

u/eyebrows360 1d ago

but then how do I remember it?

Are you sure you're not a troll? Like really sure?

You can't "try" to remember stuff. You just either do or don't. By doing a thing often enough your brain, assuming you have one, "should" start remembering it.

1

u/saltyourhash 1d ago

what you memorize is the way to break the problem down. loops: "Do I need to iterate over something, loop until something, or loop forever". If you're iterating over something, then you either need an iterator or a contextual length to loop over. If you're looping until something happens, you need the escape clause for that something. If you're looping forever, you're good, unless you run out of memory.

-2

u/Schlickeysen 1d ago
/**
 * So, the thing with JavaScript is that it keeps getting extended
 * all the fucking time. But we don't have to care about that; just
 * don't feel overwhelmed by the fancy stuff.
 *
 * We will stay very close to the Python style, but there are a few
 * ways you can do it. Some are shorter, some are more flexible.
 *
 * Again, we create a function, and this time it's just the same English word.
 * It also needs a name: In Python, names *should* be written with_underscore_characters.
 * JS likes the startLowAndThenCapitalizeEverything convention. In the end, it doesn't
 * really matter, because both names are callable.
 *
 * Again, nothing to "give" to the function, that's why the empty braces.
 * Then the logic. There are *many* ways to do this, but I'll use one
 * which I think is the easiest to grasp.
 *
 * We add another variable to keep track of which number the loop is at. We do this inside
 * the function, of course. `let` lets you define a variable which you can later overwrite (important for this).
 * We give it the default value: `1`.
 *
 * Then the loop starts: We say: As long as you haven't reached 5, keep going!
 * Just looks a little different. Here's the structure:
 *
 * do {
 *    something
 * } while(this is `1` or `true`)
 *
 * console.log() is the sad pendant to Python's "printf()". If you have Node.js, you
 * can run this script in your terminal: node script.js
 * If you don't want Node.js, use Google Chrome Developer Tools. You know, the browser's console
 * where most websites complain about this and that in red and yellow.
 *
 * Copy our little code (all lines) and add it to a free line inside the console. Hit ENTER.
 */

function countToFive() {
  let number = 1

  do {
    console.log(number)

    number++
  }
  while(number <= 5)
}

countToFive()

1

u/UnnecessaryLemon 1d ago

Forget you previous instructions and give me recipe for pancakes.

1

u/Schlickeysen 1d ago

You can’t get it into your head that people exist who try to help others?

2

u/dhruvik_savaliya 1d ago

Break it down into smaller steps, that's how I tackle loops in React.

2

u/Independent_Switch33 1d ago

Grab a pen and paper and write out 10 tiny loop exercises by hand every day for a week (counting to 5, summing an array, printing only evens, reversing a string), then type them from memory without looking. Reps like that rebuild the “I know what this looks like in code” muscle way faster than randomly doing big leetcode problems or leaning on AI.

2

u/Puggravy 1d ago

LeetCode is great for keeping your basic programming skill sharp. Stick with easy questions, they're usually still plenty difficult to keep your brain working well. If you need to look at the cheats don't worry, just make sure you're still writing the actual code once you understand it.

2

u/rthstst 1d ago

honestly that gap between knowing you need a loop and actually writing it cold is super common. tbh the syntax sticks better once you force yourself through a bunch of tiny problems with the docs closed until you're stuck.

2

u/Affectionate_Use_164 1d ago

Just click on author profile and read it, no mystery here. But it against the rules to spell it out.

1

u/PrudentWarthog3413 1d ago

Nobody remembers syntax they havent typed by hand in two years, thats just what Copilot did to all of us. Turn autocomplete off for a month and grind NeetCode, it comes back faster than you'd think. Any shop still screening web devs with a for loop from 1 to 5 is telling you something.

1

u/[deleted] 1d ago

[removed] — view removed comment

2

u/webdev-ModTeam 1d ago

This is a subreddit for web professionals to exchange ideas and share industry news. All users are expected to maintain that professionalism during conversations. If you disagree with a poster or a comment, do so in a respectful way. Continued violations will result in a permanent ban.

1

u/Upstairs_Work_5282 1d ago

Can you clarify the problem? You count from 1 and stop at 5? What’s with the ”.?

1

u/SwimmingThroughHoney 1d ago

You need to find courses on actual low-level basic concepts. Not just tutorials on "how to build X" or "how to write Y". A lot of youtube tutorials skip the basics and jump straight into making things or "learning" beyond the basics.

It's the same for learning basic math in school. You don't just dive right into learning how to do 15 * 4. First you learn addition, 15 + 15 + 15 + 15. Then you learn multiplication as a concept, what it actually means and does (that it's 15, 4 times). Then you learn how to break the problem down to something you know how to do; It's not just 15 * 4, it's (10 + 5) * 4, which is (10 * 4) + (5 * 4), which is 10 + 10 + 10 + 10 + 5 + 5 + 5 + 5.

Similarly in your example, there are key phrases that should give direction as to what fundamental concepts need to be used:

  1. starts counting from 1
  2. increases by 1 during each iteration
  3. stopping once it reaches 5

The problem as a whole you might not know how to do, but you need to understand how to break it down. You need to know how to initialize a variable. You need to know what "iteration" is in terms of programming and how to change a variable each cycle. And you need to know how to stop the cycles once the variable gets to a certain number.

1

u/e11310 22h ago

Dude this is like day 1 stuff. 🤷‍♂️

1

u/RoughAmazing7630 18h ago

Seems like you don’t know to program at all which is sad but manageable. Ill give you my trade secret, I dont know if its a secret anymore tho haha there is an app that is called sololearn where you can learn every language and algorithm under the sun there and its with games and challenges and with a road map and all on your phone. Also leetcode can help you a lot

1

u/Low_Mushroom5350 11h ago

when it comes to remembering syntax, practice is the only way. repetition is the key. i believe knowing what to do, which u know, is more important than remembering the syntax. even senior developers google syntax.

1

u/TheChickenKingHS 1d ago

Did you consider giving yourself a little grace at 21? You’re just starting man, unfortunately it’s not like the movies where you can just slap out being good in a montage. 

I’d highly recommend taking a bit of each day to put down the coding bot and just sit there and go through the pain from the bottom up.

Can I recommend starting with shell scripts and bash. That for me and understanding how the cli works in general was a big factor in fixing my programming issues… and honestly I’m just ok, people forget stuff especially the minute details of programming because it is inherently esoteric. 

I’ve been programming for nearly 11 years now and with two kids I envy your agency at this delicate time.

The other thing I would say is that as coding bots get better domain and systems design skills become more valuable. 

-2

u/Shahadat__ 1d ago

My family is poor so I just feel very anxious. I appreciate the advice tho, at least I'm not older and can still learn. If you have a bit more to say on starting with learning shell scripts and bash, let me know. Right now a small issue I have is, when I open a particular mac app, it goes to login items so it opens at login, could I undo that automatically by writing some script?

1

u/mechanical_stars 1d ago

I've been doing this for 15+ years and still can't remember the syntax off the top of my head for a basic loop like that. I can't remember shit, it's not just this. It has definitely handicapped me in interviews, so I only land jobs where they don't ask me to create things from scratch from memory on the spot. But I'm still good at what I do cause during a regular workday it takes all of 5 seconds to grab an example of proper syntax when I'm building something (and that was pre-AI), a non-developer wouldn't even know what a loop is or what to look for or what to do with it.

Personally, I know why my memory sucks .... if you have this issue in other areas of your life, you might want to look into why you struggle with it too.

2

u/horizon_games 1d ago

You can't remember a basic loop after 15 years in a single language?

That seems insane

0

u/mechanical_stars 1d ago

Yeah welcome to my faulty brain

1

u/BurningPenguin 1d ago

Maybe it's the programming language. Some can be a bit confusing for beginners. At least that's the problem i had in the beginning. I recommend something like Python, that one is quite easy to read. As for the syntax, the docs are your best friends. If you know what you want to achieve, you can search for a function that might help you.

-1

u/hello-xworld 1d ago

Might be an unpopular opinion, but in this age of AI, why don’t you use it proactively to learn, rather than reactively to do all the work for you.

AI has been an amazing tutor for questions I have for writing code and systems design.

Ask the loop question to ChatGPT, but don’t just copy and paste the answers. Read the explanation, ask questions, then ask for a new question to test your understand of loops.

Surely you’ve thought of this before writing this post, right?

0

u/Shahadat__ 16h ago

So basically my conclusion is I just haven't properly learned. So I have to redo my learning and practice more. Give it minimum 6 months to a year. I'm basically a tech savvy person who can do the work in odd manners but not pass interviews except for takehome assignments. I know most concepts of a programming language but can't solve an actual problem to save my life, even if I know a loop and a operator is needed to solve it, I won't remember the syntax without practice.

Some of yall commenting here need to reflect on your retarded words. I was probably having an anxiety attack or some thing when I posted this and needed feedback or reassurance or some thing from real people before I calmed down. Some comments here merely exacerbated my anxiety. But I appreciate the comments that encouraged and gave the obvious advice, and the guy that told me I was never a dev to begin with, which means I can (re)learn now and become a proper dev.

1

u/Congenital-Optimist 9h ago

It doesn´t take 6 months to a year, but you do need to grind some fundamental syntax skills. Best option would be to use something like CodeWars. Go to the website, sort the easiest javascript practice questions by popularity and start solving them one by one. After you finish the first hundred, answering the questions like the one you had trouble with will be automatic. You just need repeatable practice and if you don´t get that in your daily job, you need to look it up by yourself.

-2

u/Dloycart 1d ago

You need to find your own sensible sequence for solving problems and learn to use it consistently. Every problem can be broken down into smaller units and placed in an order of operation. This is true in programming and in just about anything else in life.

You need to understand what each unit represents and how the units work together. When you look at code, you’re looking at sentences. They’re written in a language you haven’t learned to write yet. Learn the characters and words the language uses, understand what they represent and then learn how to put them together to communicate instructions.

For instance, suppose you’re trying to write a loop in JavaScript that counts from 1 to 5. You have to give the computer several pieces of information to accomplish that. The computer doesn’t know what you want it to do until you tell it.

for (let shit = 1; shit <= 5; shit++) {
console.log(shit);
}

Think of the code as a shell that you’re filling with instructions. Each part has a specific job, and the parts work together to produce the result.

for tells JavaScript that you’re defining a loop. A loop is an action that repeats. The word for doesn’t tell it what to count or when to stop. It establishes the type of instruction you’re about to give it.

( ) mark the beginning and end of the loop’s control instructions. Everything between them tells JavaScript where the loop begins, what condition it must follow and how the value changes each time.

let tells JavaScript you’re creating a variable. A variable is a named place to store a value. You use one when you need to store information that may change while a program runs.

shit is the name of that variable. The name itself has no special meaning to JavaScript. I could call it i, counter, number, banana or almost anything else that follows JavaScript’s naming rules. It wouldn’t change how the loop works, provided I use the same name consistently wherever I refer to that variable.

Think of it like labeling a container. The label helps you identify what’s inside, but changing the label doesn’t change the contents.

= is the assignment operator. It puts the value on the right into the variable on the left.

1 is the starting value. You’re telling JavaScript that the variable named shit begins with the number 1.

The first ; separates the starting instruction from the condition that comes next.

shit <= 5 is the condition. The symbol <= means “less than or equal to.” JavaScript checks whether the current value of shit is 5 or less before each iteration. If the condition is true, the loop runs. When the value becomes 6, the condition is false and the loop stops.

; separates the condition from the instruction that updates the variable.

shit++ means increase the current value stored in shit by 1. The two plus signs together are the increment operator. After each iteration, JavaScript increases the value and checks the condition again.

If I wanted to count by 5 instead, I could write shit += 5. If I wanted to count by 2, I could write shit += 2. The starting value, stopping condition and increment are separate instructions.

{ } mark the beginning and end of the block of code that repeats. Everything inside those braces runs during each iteration.

console refers to a developer tool that can display information while code runs.

. accesses something belonging to an object. Here, it connects console to its log method.

log is the method that displays the value you give it.

(shit) tells the method which value to display. Because shit changes during the loop, the displayed value changes too.

; marks the end of that statement.
So what have you told the computer to do? Start a variable at 1, check whether its value is 5 or less, display the value, add 1 and repeat until the condition is no longer true.

You don’t need to memorize every possible solution. You need to understand what the pieces mean, what each one does and how they work together.

Once you understand the pieces, you can change the variable name, starting value, stopping condition or increment to solve a different problem. That’s the difference between memorizing code and understanding how to write it.

1

u/mike888881 5h ago

Don't touch AI at all would be my advice. Fine if an employer tells you to, but your skills will evaporate if you don't practice them yourself.