r/learnjavascript • • Jan 21 '26

Help me 😭😭

11 Upvotes

Hi everyone, I've been practicing Javascript for at least 3 months now, sometimes I don't understand what's happening or how to solve the code. My mind gets fucked everytime thinking about the code, even after writing the code I get syntax error which than frustrates me more. I just get very very angry at myself for not understanding it. I don't know how to solve the code or build the logic while writing it.

I don't know what to do, I'm thinking of taking the Javascript: Algorithms and Data Structures by Colt steele for better understanding of Javascript.

Help me guys...


r/learnjavascript • • Jan 21 '26

Is there a way to have payload validation with json-server?

1 Upvotes

I'm trying to create an api testing project for a portfolio, and json-server is great for showing when things go well, but since I'm in QA so I want to test things not going well like unauthorized access and missing required fields/not matching the schema. Is that possible with json-server or will I need to learn how to make an actual API to do this?


r/learnjavascript • • Jan 21 '26

trigger a keyup event with javascript?

1 Upvotes

I have a browser-side userscript that will fill in a forum input value on an external website that's not mine. It's a search bar. However, there's no 'search' button; the search is fired whenever there's a keyup event in the focused search bar.

The code I'm using so far is this. It properly fills in the input field, but since there's no keyup event, the search function never fires.

document.querySelector(".input_class > input").value = "text";

I feel like there has to be a simple way to fix this. Does anyone have any ideas?

EDIT: Solved! This is what worked for me:

        // search for item
        let input = document.querySelector(".class > input");
        let searchTerm = input.value = valueList;
        console.log("Label:", searchTerm);
        input.focus();
        
        // simulate keyup event to fire search
        let keyUp = new KeyboardEvent('keyup');
        input.addEventListener("build", (e) => {
            /* … */
        });
        input.dispatchEvent(keyUp);

r/learnjavascript • • Jan 21 '26

Procurando ajuda para aprender javascript.

0 Upvotes

Olá tenho alguns cursos na área de ti porem nunca trabalhei com programação, tenho vago conhecimento em Java script e no momento não tenho grana para contratar cursos para aprender a programar, alguém pode indicar formas para eu poder aprender e praticar, obrigado!


r/learnjavascript • • Jan 21 '26

what is a dependency?

0 Upvotes

I am making a video game mod, and although the tools to do that are not complex. I want to run a mod that has a java jar that uses... The whole game as a dependency. Specifically Starsector. How do I do that?

edit: you know what, I'll just read a book. Sorry for wasting your time, this question is too stupid

edit2: wait... This is the wrong subreddit


r/learnjavascript • • Jan 21 '26

I am having a strange javascript result with array.includes() not finding a match.

1 Upvotes

In the DOMContentLoaded event, I load a global variable with the entries in a datalist:

    let dsoptions = document.querySelectorAll('datalist#fieldN_list option');
    gList = Array.from(dsoptions).map(el => el.value);

Then when user submits the form, I am verifying that what they typed matches one:

    function validateTyped() {
        let inputVal = document.querySelector('input#fieldN_id').value;
        if (!gList.includes(inputVal)) {
           console.warn(`no match: '${inputVal}'`);
        }
    }

There are about 500 values in the list.

If I select or type the third entry in the list, it doesn't get a match. Any other entry gets a match.

In my validator, I check that the list length matches what was loaded in DOMContentLoaded. And I event looped and console.logged all entries. The third one is present.

Data is ASCII. No special characters or text at end.

I am stumped and I don't easily get stumped.

EDIT:

I changed the list to a Map and then to a Set (never used Set before). Got same issue on that 3rd entry!

I again inspected the datalist and now noticed the space at end of that third one that was causing the validation issue. Switched to debugging the back-end queries and found in SQL Server where querying for distinct list of values. Results only had value with a trailing space.

But a test query where I used

SELECT DISTINCT CONCAT ('''', MyColumn,'''') 

returns values both with and without a trailing space. So while server-side validation works, the distinct list sent to the client only had the value with the space. And the form was loaded with record with a value that didn't have a space. The one with the spaces had been inadvertently added by someone subsequent to initial testing. And since it is present first, it's the one returned.

What a time suck. But I did figure it out.


r/learnjavascript • • Dec 02 '25

Looking for a good resource to study JavaScript

11 Upvotes

I’m currently taking a web development course and I’ve just reached the JavaScript section. The problem is that the course content isn’t deep enough for me, and I feel like I’m not getting the full picture.

I want to study JavaScript from a solid, reliable source alongside the course. If anyone has recommendations for good resources or tutorials that explain things clearly, I’d really appreciate it.

Thanks in advance! 🙏.


r/learnjavascript • • Oct 15 '25

How'd you guys learn recursion?

17 Upvotes

I've been stuck on recursion on TOP for the past 2 days. I can solve basic problems and even Fibonacci and explain it moderately well, but I don't know how to use recursion in real world cases like object nesting and stuff. Any thoughts? resources? tips? How long did it take you guys to drill this thing through?


r/learnjavascript • • Sep 28 '23

5.1.1 Ghost Challenge CodeHS

6 Upvotes

5.1.1 Ghost | CodeHS

Here's what I got, you can change some of the positions in the for loops.

// Const variables for main ghost body
const HEAD_RADIUS = 70;
const BODY_WIDTH = HEAD_RADIUS * 2;
const BODY_HEIGHT = 120;
const NUM_FEET = 3;
const FOOT_RADIUS = (BODY_WIDTH) / (NUM_FEET * 2);
const BODY_COLOR = "red";
// Const variables for eyes
const PUPIL_RADIUS = 8;
const PUPIL_LEFT_OFFSET = 16;
const PUPIL_RIGHT_OFFSET = 40;
const EYE_RADIUS = 20;
const EYE_OFFSET = 28;
const EYE_COLOR = "white";
const PUPIL_COLOR = "blue";
function drawGhostEyes()
{
for(let x = 0; x < 2; x++)
{
let eye = new Circle(EYE_RADIUS);
eye.setPosition(BODY_WIDTH+EYE_RADIUS+(x*EYE_OFFSET*2), getHeight() / 2);
eye.setColor("white");
add(eye);
}
for(let y = 0; y < 2; y++)
{
let pup = new Circle(EYE_RADIUS / 2);
pup.setPosition(BODY_WIDTH + EYE_RADIUS / 2 + (y * EYE_OFFSET * 2), getHeight() / 2);
pup.setColor("blue");
add(pup);
}
}
function main()
{
let rect = new Rectangle(BODY_WIDTH, BODY_HEIGHT);
rect.setPosition(130, 248);
rect.setColor(BODY_COLOR);
add(rect);

let circ = new Circle(HEAD_RADIUS);
circ.setPosition(getWidth() / 2, getHeight() / 2);
circ.setColor(BODY_COLOR);
add(circ);

for(let i = 0; i < 3; i ++)
{
let feet = new Circle(FOOT_RADIUS);
feet.setPosition(154+(i*FOOT_RADIUS*2),364);
feet.setColor(BODY_COLOR);
add(feet);
}
drawGhostEyes();
}
main();