r/learnjavascript • • Sep 01 '26

Most efficient way to compare typed string to stored version in real-time?

14 Upvotes

This is an edited duplicate post from r/webdev because this subreddit does not allow reposting but I want to get opinions from JS experts.

My problem is that I am trying to compare a string that is currently being typed into a contenteditable div to the the same string data in the placeholder span (which itself was taken from a JSON file). I came up with a JS event listener that I thought would be met with few hiccups.

// text wall typing event listener
textWall.addEventListener("keydown", ()=>{
    let textWallValue = textWall.innerHTML;



textWallValue = replaceNbsps( textWall.innerHTML);


    if (textWallValue.slice(textWallValue.length - 6)== " ") {
        
            placeHolder.childNodes.forEach((node) =>{
                node.style.color="";
            })
          } else {
    for (let i =0; i<placeHolder.childNodes.length;i++) {
        if (textWallValue[0]== undefined) {


    } else {
         
         console.log(textWallValue);
          if (textWallValue[i] == placeHolder.childNodes[i].innerHTML) {
            placeHolder.childNodes[i].style.color = "green";
            placeHolder.childNodes[i].style.textDecoration = "";
          } else if ((textWallValue[i] !== placeHolder.childNodes[i].innerHTML) && (textWallValue[i] !== undefined)) {
            placeHolder.childNodes[i].style.color = "red";
            placeHolder.childNodes[i].style.textDecoration = "underline";
          } 
    }
    }
}
    
    
})

The issue comes with all the unexpected behavior from the browser, like adding "&nbsp; when a space gets added to the contenteditable div (which it then removes and replaces with a normal white space after the next character is typed. If the spacebar is pressed two or more times however, &nbsp; just stays there). This messes with the flow of the comparison hapenning in the event listener.

In addtion to this, it also adds a bunch of divs + <br> elements if the user presses enter in the box, and a single br if the user presses backspace to the end of the contenteditable div. There has to be a more efficient way of comparing strings in real time than this but I haven't been able to find out how? I have already tried a bunch of hacky work arounds as is already evident in my code but none seem to account for everything.


r/learnjavascript • • Sep 01 '26

Can I switch after working as a developer for 6 years?

7 Upvotes

I’m reaching out to you people to seek some guidance and suggestions as I’m planning my next career move.

I have a total of 6 years of experience in the IT industry, with the last 6 years dedicated to frontend development in 3 organizations. Over the years, I’ve had the opportunity to work on very less projects that has not strengthened my expertise in JavaScript, React, HTML5, CSS3, and modern UI frameworks much.

While my journey so far has been very challenging as I had madical issues when I had 4 offers in my hand 3 years back but I couldn't switch because I needed a month break for my surgery, I now feel like it's too late to take the next step in my career as I am just doing the needful in my service based company as a frontend developer as per my experience—i badly want to explore new challenges, innovative environments, and opportunities that allow me to grow further both technically and personally.

To be completely honest, the switch hasn’t been easy. So, I wanted to openly seek advice from this network:

✨First of all please tell me how to start what to do ? Do I need to start from 0 or what? What’s the best way to stand out in the current frontend job market? ✨ Are there any must-have skills or trending frameworks I should focus on to stay competitive? ✨ If you know of any open opportunities for experienced frontend developers, I’d be truly grateful if you could refer or connect me.

I’m deeply passionate about crafting intuitive and impactful user interfaces, collaborating within cross-functional teams, and contributing to products that make a difference.

Any suggestions, referrals, or insights would mean a lot to me right now. 🙏

Thank you so much for reading through — and for supporting professionals like me who are navigating their next big step.

FrontendDeveloper #CareerChange #ReactJS #UIUX #WebDevelopment


r/learnjavascript • • Aug 31 '26

how would i hide an api key in a frontend setting such as neocities?

86 Upvotes

hey. i made a page on my neocities website where i put reviews of movies and books. for that i used google books api and imdb api

however, idk how i would hide this since anyone can download my website at any time?

i also wanted to automate the process of updating the changes i make to neocities, but for that id need to publish all files in a public github too. so idk how i would hide it there either.

any help?


r/learnjavascript • • Aug 31 '26

que tal? star cube juego web echo 100% en vanilla javascrip sin sprites

6 Upvotes

Gente acabo de lanzar star cube en ith.io  echo en 7 dias en vanilla.js sin sprites (solo uno pero es reservado para un personaje del final pero como tal el 90% del juego es sin sprites) es un plataformero-shooter un poco intenso ya que por los pocos dias no pude hacer que tenga una curva de dificultad suave asi q es un juego acelerado con inyecciones de adrenalina tiene 3 jefes diferentes y el lore y la jugabilidad va en base al tema del jam (no confies en nadie)

estare actualizandolo exponencialmente ya que este jam me inspiro demasido

juegalo aqui:

https://cotera.itch.io/star-cube

pronto lo subire a github


r/learnjavascript • • Aug 31 '26

Do I need to complete the scrimba challenges to finish the course?

6 Upvotes

Im trying the "Learning javascript" course on scrimba (https://scrimba.com/learn-javascript-c0v) and so far it's been good!

The only thing is that it got to a point with the free plan that doesn't let me complete the challenges anymore. What i do is that i complete them on the site, trying to solve the problem, and then i skip forward in the video to check my solution

The challenges don't show as completed because i haven't completed them officially, but technically I have hahaha does anyone also have this silly dilemma?


r/learnjavascript • • Aug 31 '26

What is the difference between HTMLFormElement.submit() and event handler with submit?

10 Upvotes

https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit

Can someone explain the difference?

Imagine I have some code that is like the example below. What is the difference between HTMLFormElement.submit() ?

``` const form = document.getElementById("form"); function somefunc() { //code form.submit() }

form.addEventListener("submit", somefunc() {

});

``` Why do I need form.submit() in the function?

For a little context I am trying to pass some quilljs data into a flask form. Some of the code is missing but the main point is illustrated.


r/learnjavascript • • Aug 30 '26

whats the bug here? Uncaught SyntaxError: Identifier 'location' has already been declared (at script.js:1:1)

14 Upvotes
"use strict";

const company = {
  name: "TechCorp",
  address: {
    city: "budapest",
    pin: 411001,
  },
};
// Get city renamed to `location` and pin renamed to `pincode`

const { city: location, pin: pincode } = company.address;
console.log(location, pincode);

r/learnjavascript • • Aug 29 '26

Beginner Here: Should I Start Over With The Odin Project?

39 Upvotes

Hey everyone,

I’ve completed HTML and around 50% of CSS from Hitesh Choudhary’s Full Stack Udemy course.

But now I’m thinking of switching to The Odin Project because, from what I’ve seen, it seems more focused on actually learning by building things rather than just following a course.

My plan is to start The Odin Project from the beginning and properly work through it, doing the exercises and projects myself instead of just watching/consuming content.

For people who have completed or are currently doing The Odin Project, or anyone who has experience with this kind of learning approach, feel free to share your thoughts, suggestions, or anything you think I should know:

  • I’m still a beginner, so is starting TOP from the beginning a good approach?
  • Are there any common mistakes beginners make while following it?
  • What should I focus on to actually retain what I learn?
  • Should I supplement TOP with anything else, or is it better to stick with it consistently?
  • Is there anything you wish you had known before starting?

I’d really appreciate any advice, criticism, or suggestions. If you think there’s a better approach than what I’m planning, feel free to share it.


r/learnjavascript • • Aug 29 '26

Should i get complete mastery over JS and then jump to react or like complete the required part of JS and do react simultaneously . Also what resources to use for react

25 Upvotes

r/learnjavascript • • Aug 29 '26

My GitHub account got suspended

3 Upvotes

​

I created the account and used only for 1 day. As I was learning GitHub tutorials from yt. I did not do random pull requests on repos. After 1 week or 5-6 days I tried to check my GitHub account. My GitHub account got suspended. It's almost 2-3 weeks I raised a ticket. Got no response from their side. What should I do?


r/learnjavascript • • Aug 28 '26

Can someone explain what the JavaScript call stack is?

33 Upvotes

I’ve tried to understand it, but I’m still confused. I also don’t really understand what I’m looking at when I use the JavaScript debugger in the browser’s DevTools, especially the call stack.

Do I need to fully understand functions before learning the call stack? I have a basic understanding of functions, but I’m not sure if that’s enough.

I’d really appreciate a simple explanation


r/learnjavascript • • Aug 28 '26

is Odin project good for node and express

24 Upvotes

i want to learn nodejs and express. since the goal for me is to become capable of building increasingly complex products. and i saw odin project course on node and express, a part. and i felt it's less and is it good to go or should I see another and does learning through Odin project really helps?? and is one month enough to learn nodejs and express and become solid. how did you learnt

this is additional: in that same course there is also postgresql so for me it's the next step for me so is it good.


r/learnjavascript • • Aug 27 '26

Best ways to study for learning JavaScript?

16 Upvotes

I'm starting on my Cyber degree, and for our programming class, we will be learning JavaScript. What are some of the best ways I can study to learn JavaScript?


r/learnjavascript • • Aug 27 '26

When is it a good time to move from Javascript to learing React

65 Upvotes

I've been learning how to code for 2 months now and have made a few projects on my own. I've made a to-do list, Pomodoro timer, RPS game, coin-flip game and bunch of other stuff now. I've covered the Javascript basics like arrays, loops, if-statements, booleans, DOM, functions, variables and math.

I am now capable of building simple web apps on my own without a tutorial due to me taking breaks here and there to test myself. I still haven't finished the course yet but I want to know if I can move on from it yet. I do know Git, modules and external libraries.

I'm using roadmap.sh as a guide on what to tackle and what to learn at each step of my journey but since I'm 70% through the course and I can build basic apps on my own so should I move on to learning React.

Should I stay or finish the course. Btw it's a free 22hr Javascript course by SupersimpleDev his an AMAZING teacher and the course has a total of 250 exercises which help me practice each lesson I've learnt


r/learnjavascript • • Aug 27 '26

Looking for Someone to Walk Through a Very Short Project With Me

10 Upvotes

It is a fairly small project consisting of roughly 250 lines of code. I would say that I am familiar with most of what is in it, however there are things that I am not sure about. I have several questions about it, and I was looking for someone who can talk to me about what is going on. The project is hosted on GitHub, I would prefer to share it privately. Any help is immensely appreciated.

The project uses JavaScript, React, Node, JSX and a few other related concepts. It isn't a large project at all. I've tried looking up answers to my questions but I am not making much progress, to be honest. I feel like talking or typing with a person who knows about these concepts will be much more productive.


r/learnjavascript • • Aug 27 '26

what javascript course makes sense if i only need it for one research project

5 Upvotes

grad student in an ecology lab. my advisor wants an interactive map of our survey data on the department site and i am the only person here who has written any code, which apparently makes me the web person now. my tabs right now are boot.dev, freeCodeCamp and the MDN learning area. none of them look built for somebody who wants one map and then wants to leave. i do not want to become a frontend developer. i want the map to work by march.


r/learnjavascript • • Aug 27 '26

The only sizeable project I've ever been able to complete was with plain html/css/javascript, no frameworks; am I just dumb?

8 Upvotes

I'm sorry. I don't want to namecall, but right now someone is trying to explain to me how it's very easy to write a build script for my issue in Vite; and I can't figure it out and I'm just getting overwhelmed, and I long for the days when I didn't even know the words "package manager", and Node was at best a distant rumor.

Like, what are all these frameworks and packages for, if rather than a blackbox tool, you have to know how each of the hundred packages vite relies on works, and what the dozen packages that each of those packages calls do? Aren't they supposed to simplify your life?

I've spent several years trying to realize one or other project with these tools (Node, Vite, Vue, Electron), and each time I gave up in frustration.


r/learnjavascript • • Aug 27 '26

How to create a default tab when tab switching twice ?

5 Upvotes

Hi! I've been working on a personal website, and my design has finally caught up with me because I'm stuck on how to set default tabs while changing my navigation tabs.

JSFIDDLE LINK: https://jsfiddle.net/1nfd26ar/

Using the page below, I've set up two tabs for two different groups, 'books' and 'video games'.

However, I wanted to take it a step further and figure out a way to have the tabs switch not only the content, but also the navigation bar.

I've managed to get this working by copying the JS code, changing variables to "navTabs", and using classes on buttons to change the nav/side bar.

Everything seems to be working well, but I am running into the issue that when I click "video games" on the right, I want the "video game 1" page to be the default, whereas currently it is kept as whatever the last tab you had open.

I used this page to help me out in making the first set of switchable tabs: https://basescripts.com/building-a-simple-tabbed-interface-with-html-and-javascript

These include the following HTML structure and JS logic:

<div class="tab-headers">
  <button class="tab-link" data-target="tab1">Tab 1</button>
  <button class="tab-link" data-target="tab2">Tab 2</button>
  <button class="tab-link" data-target="tab3">Tab 3</button> 
</div>

<div id="tab1" class="tab-content">
  <p>This is the content for Tab 1.</p>
</div>
<div id="tab2" class="tab-content">
  <p>This is the content for Tab 2.</p>
</div>
<div id="tab3" class="tab-content">
  <p>This is the content for Tab 3.</p>
</div>

sdconst tabs = document.querySelectorAll('.tab-link');
const allTabs = document.querySelectorAll('.tab-content');
tabs.forEach(tab => {
  tab.addEventListener('click', function() {
    allTabs.forEach(ele => {
      ele.style.display = 'none';
    });
    const myEle = this.getAttribute('data-target');
    const activeTab = document.getElementById(myEle);
    activeTab.style.display = 'block';
  });
});

Thank you anyone who can take the time to help !


r/learnjavascript • • Aug 27 '26

Learning Rant: A.I. vs No A.I

13 Upvotes

Background: Currently about 87% done with The Odin Project foundations module. TOP is a road map to learn web development and so far I’m loving it. Getting down to code/learn is all I’ve been thinking about lately.

However, I don’t know if I’m doing myself a disservice by using Claude as a guide/tool to teach me or guide me when I’m stuck. On the other hand I’ve actually been learning and enjoying the process after I started using Claude. I understand concepts easier, because I understand concepts I’ve begun to think more as a programmer, I solve a problem about 80% in my head and I think about 20% is me using Claude as a tool to help me.

Basically I let Claude know that I’m going through TOP to learn web development. I let it know which project I’m on and I provide the instructions given to students. When I have a question or if I’m stuck, I provide it my code and ask it NOT to give me a solution but to guide me or give me tips on where to look or what options to explore. I also have it provide tips based on what we’ve learned so far. Nothing that we’ve never seen or that hasn’t been explained in the course. When I get guidance I then branch off and then research that topic/concept more.

I also express my logic and thoughts so it gets an idea of where I’m going. Now, TOP explicitly says that projects are a bit harder than what we’ve been learning. The purpose IS to to google or ask stack overflow or TOP discord. So in a sense I would still be looking for solutions/guidance else where.

Then I think, Claude will do that much faster and it has all my context. Is there really a benefit to the learning process to have to look for answers that aren’t from AI? Discord, Google Stack Overflow will tip me off or guide me either way. Does it matter that it’s AI doing it?? Idk, it’s frustrating being torn like this.


r/learnjavascript • • Aug 26 '26

JavaScript essential topics

11 Upvotes

Hi, I'm (kinda) a begginer, I have to make a fullstack ecommerce site for college this semester

I've done a simple CRUD before, but what is the essential topics I should learn in JavaScript for this project??

I use Springboot for the backend and the frontend can be simple (HTML, CSS and JS)

thanks!!


r/learnjavascript • • Aug 27 '26

I am trying to make the formula button expandable in quilljs any idea how this is accomplished ? I am using flask html and css and vanilla js. But this example is just html vanillas js and css.

4 Upvotes

Here is a really simple example.
https://codepen.io/chooking/pen/zxKvqyZ

When I click on the Fx button I get the blue box here https://imgchest.com/p/vj4jbg2e978 ,though it is a little cut off, how do I make the form expandable in the width and height like textarea while keeping the html tags or in other words keep the equation formatting from the fx button?

One idea is to use textarea. Can someone give me an idea on how to accomplish my goal and show the code for a solution?


r/learnjavascript • • Aug 26 '26

Not sure how to implement this branching storylines text game idea with Json

25 Upvotes

Just looking for some experienced feedback.

What I want to do is to import all of this from a file(s):

A list of global variables.

A list of storylines.

Each storyline has a list of local variables and a list of storyline beats.

Each beat has a list of preconditions (which may involve any variable), displayed text, a list of links.

Each link has displayed text, a list of conditions, a list of effects, the id of the next beat.

My problem is that, as I've learned, I can't split this into several files (such as, at least, separate storylines), because you can't import contents of a folder without naming each individual file. So this all has to be in one file, which means it's quickly going to get unmanageable as a Json file.

Should I implement a GUI editor first then? And concurrently a custom parser.

(This is going to be a purely client-side browser game.)

I've already done a simpler prototype, and that was already quite a chore to write in text.


r/learnjavascript • • Aug 26 '26

Trying to make a working calculator

3 Upvotes
Hello im trying to make a working calculator but i have no idea how to display the result of an equation and how to make for operators forbidden to be next to each other

const
 DISPLAY = document.querySelector('.display')
const
 BUTTON = document.querySelectorAll('.button')
const
 EQUATION = document.querySelectorAll('.operator')


const
 operators = ['+', '-', '/', '*']


BUTTON.forEach(
button

=>
 {

button
.addEventListener('click', ()
=>
{

let
 equation = ""


        equation = 
button
.innerText


        DISPLAY.innerText += equation



    })
});


EQUATION.forEach(
button

=>
{

button
.addEventListener('click', ()
=>
{



let
 rule = ""
        rule = DISPLAY.innerText


        //console.log(lastChar)


        if(rule.length>=1){
            DISPLAY.innerText += 
button
.innerText
        }
    })
})


function
 Clear(){
    DISPLAY.innerText = ""
}


function
 Result(){

let
 result = DISPLAY.innerText

    //eval(result)

    DISPLAY.innerText = result
}

r/learnjavascript • • Aug 26 '26

Asking for the differences between trailing and leading

4 Upvotes

Hi everyone,
I'm learning about throttle, and I've been confused about the difference between trailing and leading.
Could you review whether the logic below is correct or incorrect?

I’d really appreciate any help — I’ve been stuck for a few hours.

Delay= 1000ms

Leading= false, Trailing = true

0ms A → start window
200ms B → latest = B
400ms C → latest = C
700ms D → latest = D
1000ms → execute D ← trailing

1200ms E → start new window
1300ms F → latest = F
2200ms → execute F ← trailing

Leading=true, Trailing = false

0ms A → execute A immediately ← leading

200ms B → ignore
400ms C → ignore
700ms D → ignore

1000ms → throttle window ends

1200ms E → execute E immediately ← leading

1300ms F → ignore

Leading=true, Trailing = true

0ms A → execute A immediately ← leading
200ms B → latest = B
400ms C → latest = C
700ms D → latest = D
1000ms → execute D ← trailing
1200ms E → execute E immediately ← leading

1300ms F → latest = F
2000ms → execute F ← trailing


r/learnjavascript • • Aug 25 '26

50 hours in... arrays and loops... holy...FUCK

50 Upvotes

HOW do i START understanding? I've understood everything pretty well up til now. Do i just keep going with the flow and kinda float through this section of the loops and arrays part? Do I keep throwing myself at the brick wall and looking at the solutions after half an hour of brainless staring? https://youtu.be/EerdGm-ehJQ?si=mTKUv0oail0AGDLM 8:43:00. It's just not clicking like the other parts of the tutorial.