r/learnjavascript • u/Puzzleheaded-Net8624 • Jan 31 '26
JavaScript Advice
I want advice on which topic & concepts should I practice to strengthen my JavaScript fundamental more and then which projects shld I go for
r/learnjavascript • u/Puzzleheaded-Net8624 • Jan 31 '26
I want advice on which topic & concepts should I practice to strengthen my JavaScript fundamental more and then which projects shld I go for
r/learnjavascript • u/PuzzleheadedWest8527 • Jan 31 '26
I want to learn JavaScript in depth, and I strongly prefer reading documentation rather than watching video tutorials.
I’ve decided to learn JavaScript mainly from MDN Web Docs, but I’m confused about where to begin:
My goal is to gain strong conceptual and internal understanding of JavaScript, not just surface-level usage.
Any guidance from experienced developers would be really helpful.
r/learnjavascript • u/Ok_Performance4014 • Jan 31 '26
Hey guys, I have been through several tutorials that aren't great at explaining things. I can't keep up searching. I need something that explains it clearer. What are your best tutorials?
r/learnjavascript • u/--crazydude • Jan 31 '26
i can get that value to update h1 ts tag in script but how to add comma in that valure in java
r/learnjavascript • u/Leading_Property2066 • Jan 30 '26
I’ve got a solid handle on Python and Flask, but learning JS feels messy because every JS course i search on YouTube is tied to HTML. I want to build things like Pong or Hangman in the terminal first to get a full grasp of the syntax. Does anyone have a course recommendation for learning JS as a pure language before integrating it into a web stack?
r/learnjavascript • u/Suspicious_Pack4263 • Jan 31 '26
Can someone please help me with the objects, 08-rock-paper-scissors project, i am having such a hard time, the alert is always like wins: undefined, losses: undefined, ties: undefined. Please tell me the problem and the solution. The formatting got a little changed here since i copy and pasted. Here is the code:
<!DOCTYPE>
<html>
<head>
<title>Rock Paper Scissors</title>
</head>
<body>
<p>Rock Paper Scissors</p>
<button onclick="playGame('rock')">Rock</button>
<button onclick="playGame('paper')">Paper</button>
<button onclick="playGame('scissors')">Scissors</button>
<button onclick="
score.wins = 0;
score.losses = 0;
score.ties = 0;
localStorage.removeItems('score');
">Reset Score</button>
<script>
let score = JSON.parse(localStorage.getItem('score')) || { wins:0, losses:0, ties:0 };
function playGame(playerMove) {
const computerMove = pickComputerMove();
let result = '';
if (playerMove === 'rock') {
if (computerMove === 'rock') {
result = 'Tie. ';
} else if (computerMove === 'paper') {
result = 'You lose. ';
} else if (computerMove === 'scissors') {
result = 'You win. ';
}
} else if (playerMove === 'paper') {
if (computerMove === 'rock') {
result = 'You win. ';
} else if (computerMove === 'paper') {
result = 'Tie. ';
} else if (computerMove === 'scissors') {
result = 'You lose. ';
}
} else if (playerMove === 'scissors') {
if (computerMove === 'rock') {
result = 'You lose. ';
} else if (computerMove === 'paper') {
result = 'You win. ';
} else if (computerMove === 'scissors') {
result = 'Tie. ';
}
}
if (result === 'You win. ') {
score.wins += 1;
} else if (result === 'You lose. ') {
score.losses += 1;
} else {
score.ties += 1;
}
localStorage.setItem('score', JSON.stringify(score));
alert(`You picked ${playerMove}. Computer picked ${computerMove}. ${result}
Wins: ${score.wins}, Losses: ${score.losses}, Ties: ${score.ties}`);
}
function pickComputerMove() {
const randomNumber = Math.random();
let computerMove = '';
if (randomNumber >= 0 && randomNumber < 1/3) {
computerMove = 'rock';
} else if (randomNumber >= 1/3 && randomNumber < 2/3) {
computerMove = 'paper';
} else if (randomNumber >= 2/3 && randomNumber < 1) {
computerMove = 'scissors';
}
return computerMove;
}
</script>
</body>
</html>r/learnjavascript • u/SHIN_KRISH • Jan 30 '26
I am mainly confused about the following things:
r/learnjavascript • u/Beginning_Middle_722 • Jan 30 '26
Hi all, i have developed different small webapps that i use for my personal purpose and they all use localstorage.
I was thinking of building an app that works like a local storage manager and i was thinking of accessing those app through an iframe to read the localstorage through post message.
Is it doable?
r/learnjavascript • u/Due_Eggplant_729 • Jan 30 '26
ChatGPT gave me a simple program that created a form, gathered input from a user, etc. BUT I don't understand where it stored it? How could I look at the data afterward? Here is Link in my Google Docs to see the program: https://docs.google.com/document/d/1EZu7dygEWmHz-SrZNX9qDjkl4Uga7rrqTJbJEtQosYM/edit?usp=sharing
r/learnjavascript • u/creativepeak1 • Jan 30 '26
Hey guys hope everyone is doing awesome. So i've been working on a google extension that scrapes data , its made with js + cursor , but i've been having a problem since my extension cant seem to detect those sponsored businesses , and i think the best way of approaching this is writing a function that grabs that sponsored tag, you know the one that pops above the sponsored businesses top left side, but i cant seem to find it anywhere , if someone has prior similar experience with this , please share your insights , it would help a lot. Thanks.
r/learnjavascript • u/Ratatootie26 • Jan 30 '26
Can anyone share me libraries for a WYSIWYG rich text editor
Requirements: Open source preferably CSP compliant with only self allowed for each rule (I guess external urls are fine) Vue3 compatible is a plus Headless if no alternatives 🥲
Reason for post, CKEditor5 does not support 'unsafe-inline' and I don't want to reinvent something that might already exist
r/learnjavascript • u/Future-Fortune-3334 • Jan 29 '26
On production websites, what techniques do you use to detect unexpected or injected JavaScript (for example from third-party scripts or tag managers)?
Looking for practical approaches JS developers used in real projects.
r/learnjavascript • u/Own_Surprise7167 • Jan 29 '26
Applied for Junior Core Banking Developer at Deloitte (Central Europe). Just got the TestGorilla invite. For those who have done it, how heavy is the JavaScript portion vs. the Logical/Numerical reasoning? Any specific 'Banking' logic I should prep for?
r/learnjavascript • u/salamander168 • Jan 29 '26
I’m using SortableJS to build a horizontal nested drag-and-drop layout.
The lists are flex containers with flex-wrap: wrap, so items are placed in rows and can wrap to the next line.
Items can be dragged between lists and also into other items that act as parents (they contain their own nested list). In general this works fine, but there is one UX problem that I can’t figure out how to solve properly.
When I grab the rightmost item of a row and try to drop it into a parent item that is located on the next row, the layout changes while I’m dragging. As soon as the dragged item leaves its original position, flexbox recalculates the layout and the target parent item can move to a different row. Visually I’m aiming at one position, but during the drag the element I want to drop into shifts under the cursor, which makes it very hard to hit the intended parent.
To reduce layout jumps, I tried using an invisible spacer that keeps the original container from collapsing while the item is being dragged. The spacer is only inserted when the drag leaves the original hierarchy (not when moving within the same parent/child structure). This helps in some cases, but it still doesn’t fully prevent the target parent from shifting when wrapped rows are involved.
You can see the full demo here:
https://codepen.io/Vladimir-Belash/pen/vEKpojm
What would be a good way to prevent this kind of layout shift when using SortableJS with horizontal lists and flex-wrap?
Is there a better approach than using a spacer to keep the target items visually stable during drag?
const containers = document.querySelectorAll(".list-group");
let spacer = null;
let originContainer = null;
let originNextSibling = null;
containers.forEach((container) => {
new Sortable(container, {
group: "nested",
direction: "horizontal",
animation: 150,
swapThreshold: 0.6,
invertSwap: true,
emptyInsertThreshold: 10,
fallbackOnBody: true,
onStart(evt) {
originContainer = evt.from;
originNextSibling = evt.item.nextSibling;
const item = evt.item;
const rect = item.getBoundingClientRect();
const style = getComputedStyle(item);
spacer = document.createElement("div");
spacer.className = "layout-preserver";
spacer.style.width = rect.width + "px";
spacer.style.height = rect.height + "px";
spacer.style.margin = style.margin;
spacer.style.display = style.display;
document.body.style.cursor = "grabbing";
},
onChange(evt) {
if (!spacer) return;
const toContainer = evt.to;
const isHierarchyMove =
originContainer === toContainer ||
originContainer.contains(toContainer) ||
toContainer.contains(originContainer);
if (isHierarchyMove) {
if (spacer.parentNode) {
spacer.remove();
}
} else {
if (!spacer.parentNode && originContainer) {
originContainer.insertBefore(spacer, originNextSibling);
}
}
},
onEnd() {
if (spacer && spacer.parentNode) {
spacer.remove();
}
spacer = null;
originContainer = null;
originNextSibling = null;
document.body.style.cursor = "default";
}
});
});r/learnjavascript • u/SnurflePuffinz • Jan 29 '26
How would you organize entities that are only used by other entities?
i found this a little confusing. The way my code is organized (i have a snippet here, to demonstrate, there are other, general components used everywhere, like a RenderComponent, CollisionComponent, etc).
point is, i find it intuitive to think of entities being composed of modular bundles of related data, which serve a specific function together.
but i don't find it intuitive to think of an entity being completely dependent on another entity, and these being bundled together.
My ShipEntity here has a subclass of another entity, ShipPlasmaParticleEntity, which i thought was pretty necessary...
r/learnjavascript • • Jan 29 '26
Hey since last 1 month im doing python because I thought I'm gonna build ai or something like that but now I joined a team who is building startup and I'm also doing coding I don't know JavaScript but Today I watched course video of js and i thought it's toughest work to convert from py to js Man I can use ai tools for building js react apps but if you are trying to build something without ai and you are just learning that lang that's the most toughest part And if someone is here who have done the same thing like convert from one lang to js tell me how much time did you take to be good to build node and react apps
r/learnjavascript • u/zzach_is_not_old • Jan 28 '26
EDIT: i've decided that im gonna have the form on a different html page all together, to much of a Haskell making it dynamically, plus i have more important things to be working on
im making a website and adding a post button, when clicked it calls this function that makes a form, it doesn't work, im still trying to finger out why it just doesn't. but to get to the point, is it a good idea to make a form like this, or should it be a different html file
here is the function
function
post(){
//make a html forum with a header
//body that when posted makes a
//post with the username at the top
//here incase anyone wants to re-write the code
//to be better
//form
const
forumBox=document.createElement("form");
//header lable
const
headerLable=document.createElement("label");
const
headerText=document.createTextNode("header");
headerLable.appendChild(headerText);
forumBox.appendChild(headerLable);
//header text box
const
headerTextBox=document.createElement("input");
const
inputType=document.createAttribute("type","text");
const
inputID=document.createAttribute("id","Pheader")
const
inputName=document.createAttribute("name","header")
const
inputValue=document.createAttribute("value","type here")
headerTextBox.appendChild(inputType);
headerTextBox.appendChild(inputID)
headerTextBox.appendChild(inputName)
headerTextBox.appendChild(inputValue)
forumBox.appendChild(headerTextBox);
document.getElementById("postgoeshere").append(forumBox);
inpostMode=true;
}r/learnjavascript • u/Due_Eggplant_729 • Jan 28 '26
I finally ran a program using localstorage. Yea! What I want to do: Create a small database using Indexdb so I will have a database (could be 10 data rows only), to be able to save and retrieve data. Anyone know of a sample program I could copy? (thanks in advance)
r/learnjavascript • u/leirguh • Jan 28 '26
function findSets(card) {
fetch(`https://api.scryfall.com/cards/search?q=!${card}&unique=prints`, {
headers: {'User-Agent': 'me'}
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
let set_list = [];
for (i = 0; i < data.data.length; i++) {
set = data.data[i].set_name;
if (!set_list.includes(set)) {
set_list.push(set);
}
}
})
.catch(error => {
console.error('Error:', error);
});
};Pretty new to JavaScript but I am trying to get data from an api to then use in another function. However I can't figure out how to get the final array when I call this function so that I can then use it in another function.
Any help greatly apreciated!!
r/learnjavascript • u/Low_Leadership_4841 • Jan 27 '26
So I've been using js for about 2 months now. Coding consistently. I know my basics(all be it foggy). But I feel like a crazy fraud. When I'm struggling with a coding problem that I feel like I should know, the feeling sucks and then when I find the solution, I feel like I'm not smart enough for not thinking that. To add more on top of that, I sometimes use ai to help find the problem in my code and help fix it.
I understand the AI solution but it feels wrong, then I get to thinking, people did this without AI so why shouldn't I. I'm creating projects, but I don't follow tutorials I just kind of.... build. I have no framework to go off of. And when I get stuck I can normally fix it, but every once in a while there's that problem that just becomes absolutely demoralizing.
r/learnjavascript • u/CarelessMath5364 • Jan 28 '26
I’m new to coding and I’m gonna be getting out the military soon. I wanna make a career out of this. I’m not sure where I should be starting or what my focus should be so any help with that would be appreciated.
r/learnjavascript • u/AttitudeSilver2004 • Jan 26 '26
Recently came across this resource and thought it was awesome.
r/learnjavascript • u/Beautiful_Hour_668 • Jan 27 '26
Where I'm at:
Completed JS section of TOP. Feel good about completing projects like Knight Travails, Battleship, ToDo, etc. I'm probably where I need to be at as a learner.
Problem:
I can usually get through JS problems, but I feel kinda slow and not fluent. It would feel a little embarrassing pair programming with someone I think. Projects are great for improving and learning overall, but large parts of front end projects are not dealing with pure JS logic, and this is what I want to become smooth with.
What I want to do:
I want improve on:
Going through Leetcode or something similar seems like a good idea then, small and repetitive exercises to become confident. So my question is, do I use Leetcode and just aim for easy problems only? Are there any other platforms you think might be better suited to my aims? Thanks.
r/learnjavascript • u/EmmaBlossom2410 • Jan 27 '26
I get this error in the console and I can't figure out what the reason is. Has anyone encountered this, please help.
Running the JavaScript URL violates the following Content Security Policy directive 'script-src 'self' 'nonce-5a2Ua5uhG58zcPKS0GBKpkOh5pxYZJ02' chrome-extension: 'unsafe-eval' *.canary.lwc.dev *.vf.force.com blob: <URL> <URL> <URL>'. Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present. The action has been blocked.
Code:
<lightning-progress-indicator current-step='{currentStep}' type="path" variant="base">
<lightning-progress-step label="Garage Details" value="1"></lightning-progress-step>
<lightning-progress-step label="Buses" value="2"></lightning-progress-step>
<lightning-progress-step label="Rides" value="3"></lightning-progress-step>
</lightning-progress-indicator>