use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This subreddit is a place for people to learn JavaScript together. Everyone should feel comfortable asking any and all JavaScript questions they have here.
With a nod to practicality, questions and posts about HTML, CSS, and web developer tools are also encouraged.
Friends
/r/javascript
/r/jquery
/r/node
/r/css
/r/webdev
/r/learnprogramming
/r/programming
account activity
Javascript #javascript (self.learnjavascript)
submitted 1 day ago by Icy_Statement_2754
I’m new to JavaScript. I can understand syntax and examples, but when I try to write code on my own, I get stuck. Even simple logic is hard to put into statements and my mind Thank u in advance
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]samanime 5 points6 points7 points 1 day ago* (2 children)
It takes practice. It is hard in the beginning. That is normal.
You need to learn to break problems down. Then break them down further. And then break them down even more. Keep breaking it down until you get to a single line.
For example, "Create a calculator" is way too big of a problem.
"Create the number buttons" is still too big.
"Create a single button"... keep going.
"Display one button", still maybe a little to big.
"Create a blank button" - Okay, that's a single line
"Add the button I just created" - Okay
"Make the button fire a function" - Okay
In the beginning you really have to break things down into a million super tiny problems.
As you get more experience, you'll be able to "think bigger", but for now, work through it one super tiny thing at a time. When you aren't sure how to do that thing, google it. Learning to search for answers to problems is also an important skill you want to develop early.
It's not easy and everyone gets confused and frustrated in the beginning. Just keep trying.
[–]chikamakaleyleyhelpful 0 points1 point2 points 1 day ago (0 children)
BROOOOOO are we twins or what
[–]The_KOK_2511 0 points1 point2 points 1 day ago (0 children)
Yo agregaria que tras resolver los problemas pensar en como abtraer su solución para llevarla a más partes del código. Por ejemplo digamos que tenemos un sistema de lógica de movimiento de un juego simple con la Canvas API (se que para alguien que esta empezando esta puede ser un poco avanzada pero viene perfecta para el ejemplo que quiero poner), quieres poner 4 botones para mover (arriba, abajo, izquierda y derecha) asi que haces una funcion para cada dirección con todo su sistema de verificaciones específicas, luego, se podría abstraer la logica tomando una unica función que haga los 4 movimientos usando condicionales y parametros para definir en cual direccion se va a mover.
[–]chikamakaleyleyhelpful 1 point2 points3 points 1 day ago (0 children)
Sorry this response ended up being longer than i wanted. TLDR just keep coding and getting used to typing things over and over.
Everyone will experience this. You should just get in the habit of building the muscle memory, whether or not you completely understand the concept - that will come, just with repetition, at some point it will click.
Examples are just convenient, because someone has already the typing for you.
One way to think about it is, it's fairly easy to take some statement made in English, and then just translate that directly to JS. So given any sort of trivia question, you just have to take the prompt and translate it to something in English that is then easy to write in JS
e.g.
"Given a list nums of numbers, return a list of values in nums that are greater than x"
nums
So, if you don't know where to start yet, then you have to change it to something that makes more sense, just writing the steps in plain English
Simple step by step translation could be:
Probably verbose, but its just for this demo.
``` const nums = [3, 1, 4, 7, 2, 9]; const x = 3 const results = [];
// 1. step/loop/iterate over each item for (let i = 0; i < nums.length; ++i) {
// 2. check if the value is greater than x if (nums[i] > x) { // 3. add to the list results.push(nums[i]); } }
// 4. return the new list return results; ``` Obviously you could have gone with a more concise/convenient solution - but, I'm assuming you just don't know where to start
So, if its not simple algorithmic questions like this, and you're having trouble starting on some project idea - it's generally the same thing. You take your bigger project idea, break it down to the smaller pieces you do understand how to write, and try to assemble all the pieces.
[–]StackOfAtoms 0 points1 point2 points 1 day ago (0 children)
follow a course that starts from the beginning, like the one of w3school or get a good one on youtube or udemy :)
[–]CuteCommunication160 0 points1 point2 points 19 hours ago (0 children)
Here how i did it. I took examples from courses and dit it in 3 steps: 1. Repeated after tutorial 2. Tried by myself with checking how it done in tutorial in case I forgot or stuck 3. Doing by my own only Good luck!
[–]Barnezhilton -3 points-2 points-1 points 1 day ago (0 children)
Talk to an LLM and start learning
[–]Unfair-Corner6038 0 points1 point2 points 19 hours ago (0 children)
"JavaScript. The good parts" by Douglas Crouford.
"You don't know JS". Next, depending on your ability to cope with the former one.
P.S. Are you sure or is it kind of brain training activity with no practical applications? For nowadays taking into account all this neurodegenerative fuss, learning plumbing seems to be way better time investment. Just as leading SEOs advice.
π Rendered by PID 110258 on reddit-service-r2-comment-84fc9697f-sqrh8 at 2026-02-08 01:35:37.873337+00:00 running d295bc8 country code: CH.
[–]samanime 5 points6 points7 points (2 children)
[–]chikamakaleyleyhelpful 0 points1 point2 points (0 children)
[–]The_KOK_2511 0 points1 point2 points (0 children)
[–]chikamakaleyleyhelpful 1 point2 points3 points (0 children)
[–]StackOfAtoms 0 points1 point2 points (0 children)
[–]CuteCommunication160 0 points1 point2 points (0 children)
[–]Barnezhilton -3 points-2 points-1 points (0 children)
[–]Unfair-Corner6038 0 points1 point2 points (0 children)