Questions tagged [javascript]

JavaScript is primarily a language focused on web development. Being a monopoly on the front end and having Node on the back end. Use this tag for questions regarding vanilla JavaScript; optionally tagged with an ECMAScript version. If you are using a preprocessor such as TypeScript please tag with that too.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
13 views

Concerns regarding Angular website scalability [closed]

I have a couple of concerns regarding code I wrote in the past on whether it is scalable and maintainable. While I am focused on maintaining scalable and maintainable code, I would appreciate any ...
Yousef's user avatar
  • 1
-1 votes
0 answers
21 views

cloneNode then reset the controls [closed]

I wrote this code below to get the template-input-group and cloneNode the data. I then have to reset all the select and input ...
Jefferson's user avatar
  • 359
0 votes
0 answers
26 views

Testing whether parenthesis are correct in a string in functional JS

This is a homework exercise and therefore has no further purpose. The writing to me feels clunky, and the typescript types on addParenthesisFactory are unreadable, ...
Tomer Kandel's user avatar
0 votes
0 answers
30 views

The Wacky World of ANSI Escape Sequences?

I just finished creating my first npm package (for learning, not competition) and published it. Now I want to ask some questions, for example: Is my method of writing code good (for later maintenance ...
Maysara Elshewehy's user avatar
-2 votes
0 answers
34 views

Learning some functional programming - would like your input on code readability [closed]

These are three different exercises I was working on. I'm new to JS and FP as well, and I'm not sure what guidelines to follow to make my code readable. My tabs got a bit borked. All code has: ...
Tomer Kandel's user avatar
1 vote
1 answer
69 views

CPU emulation library

I've started to work on a JavaScript library called vCPU with the purpose of providing a framework for emulators. vCPU is designed to be able to emulate multiple types of CPUs, with setup only ...
themirrazz's user avatar
-3 votes
0 answers
26 views

Retrieving n bits signed integers stored contiguously in memory [closed]

I'm trying to implement the minecraft protocol in TS/Node, and for the Position data type, the doc here says "x as a 26-bit integer, followed by z as a 26-bit integer, followed by y as a 12-bit ...
Fayeure's user avatar
  • 95
4 votes
1 answer
90 views

Hangman game in JavaScript

I have attempted to create a hangman game in JavaScript. Some parts of my code is a bit DRY. Basically, the Hangman class is a wrapper for all of the available actions in a typical hangman game: setup ...
Napoleon Bonaparte's user avatar
-3 votes
0 answers
31 views

It is good practice to use the setState callback to ensure that the state is updated [closed]

I have a situation where I am fetching a list from the backend. For each item in the list, I need to display a dropdown, which also needs to be fetched from the backend. I then need to check if the ...
Programmer's user avatar
-1 votes
0 answers
30 views

Efficient way to solve word scramble

I wrote this code below to automatically find all possible arrangements of letters of a word whose letters are randomly mixed up. All letters of the word are stored in an array. For example, when the ...
John's user avatar
  • 47
5 votes
2 answers
921 views

another Tic-Tac-Toe Game

I have a bit of experience in programming but not that much. I was trying to create a TicTacToe Game in Javascript. I was doing my best to have a good structure. I was thinking about using classes, ...
Cats's user avatar
  • 61
5 votes
2 answers
544 views

Simplify complexity [closed]

I came across this question which asks to create a function which will return true/false based on the passed array containing all the letters to make up the passed word. Each letter from array can ...
user282070's user avatar
0 votes
0 answers
27 views

How to shrink a react function code with firebase set/update operations

I have a function which does firebase set and update operations, but it looks messy. I want to shrink it but also make sure that it works the same. Any ideas? ...
Andrian's user avatar
1 vote
1 answer
69 views

Sine function guessing cognitive app

Please help with improving this application. It is a guessing game, for learning the values of the sine function, and boosting brain power in the process. ...
Attila Vajda's user avatar
3 votes
1 answer
111 views

Sorting the divisors of a given number

I am trying to sort all the divisors of a given number in the most efficient way. Below is my code for sorting the divisors: ...
Arjun Kumar's user avatar
4 votes
0 answers
62 views

Google App Script to take form responses submitted by teachers on their students and produce formatted PDF student reports

I'm not a programmer but, with help, I managed to make a Google Apps Script which takes reports, submitted by teachers on their students, to the Form Responses Sheet, and then selects all responses ...
StreetSavvypub's user avatar
1 vote
0 answers
23 views

User Management System: a web app for management of user records (Part II: Frontend)

Note: It's Part II of the User Management System project, focused on the frontend. See Part I here. Here's the frontend part. I want to note that I realized even back then that copy-pasting a huge ...
Sergey's user avatar
  • 541
2 votes
1 answer
100 views

Combinations of elements in array

I wrote this code to get all possible arrangements for an array containing 3 elements: ...
John's user avatar
  • 47
1 vote
2 answers
154 views

Strings to array

I've written a simple text tokenizer in JavaScript which works in my specific case, but I do not think it is maintainable (for example, if the requirement ever changed to allow newlines when ...
FromTheStackAndBack's user avatar
1 vote
1 answer
131 views

Need help condensing my code so it takes up less lines and it easier to interpret

Description is at the bottom Here is a link to all the code: Link ...
WartyWarthog123's user avatar
1 vote
1 answer
101 views

Detect a straight automatically in Texas Hold em Poker [closed]

I made a Poker-Hands tracker. The 52 cards of the game are in this program represented by their value and their type. For example Ace-heart is stored as "Ah" and 7-spades as "7h". ...
John's user avatar
  • 47
3 votes
1 answer
157 views

Sending only modified data from a table to the backend as form data

The frontend has a table with hundreds of rows. Each row consists of different inputs (text, file, ...
pileup's user avatar
  • 421
1 vote
1 answer
39 views

Reduce Redundant event listeners and selectors to make navigation scrolling and clicks more concise

Inside of this navigation function, I have a click event that scrolls to sections which are offset by the fixed header height. I also have a scroll event which changes the links' color when the scroll ...
Tami8899's user avatar
0 votes
0 answers
40 views

weekly calendar date algorithm

...
Sayaman's user avatar
  • 415
2 votes
0 answers
54 views

React draggable sliding panel

I'm building a sliding bottom panel as a React component, adapting Phuoc Nguyen's excellent draggable element tutorial. It currently looks like this: The expected behavior is: User taps on button to ...
Jimmy's user avatar
  • 21
5 votes
2 answers
427 views

Optimizing for() loops on Roman Numeral Converter JS

I'm looking for some feedback on this converter I made. It works just fine for the instructions I had, but I'm wondering what else could be done to improve it or if there's a better aproach to doing ...
Ignacio Vior's user avatar
2 votes
3 answers
1k views

Math calculation JavaScript. Am I using Objects correctly? Can I use methods / functions to shorten my code further? Also error logging?

Context- CRM system, front-end form. Requirement- Within a form users have to give a rating to a section based on user inputs, each rating has different weighting. The rating is stored in an option ...
BenDev21's user avatar
4 votes
2 answers
206 views

Is it possible to make this Minecraft Bedrock addon script less resource intensive, so that it no longer triggers performance warnings?

Following the notice that block events will be removed in a future update, I have been implementing custom block mechanics (such as crop growth and groundcover spreading) using server-side scripts ...
Quack E. Duck's user avatar
2 votes
1 answer
254 views

Efficient browser `StorageEvent` handling

I have this class EfficientStorageEventProvider, which is responsible for efficient handling of StorageEvent ...
Ivan Ivanyuk's user avatar
1 vote
0 answers
31 views

Refactor Node.js Logging Library for Improved Readability

I have a Node.js logging library that applies ANSI styling for text formatting. Currently, the code contains some redundancy and could be refactored for better readability. I'm particularly interested ...
Dinesh Basnet's user avatar
1 vote
0 answers
34 views

Svelte - Modal window with dark background and appear/disappear animations

I created this code in Svelte which will show a modal and remove it when the background is clicked, based on a native JavaScript implementation I wrote earlier. In the *.svelte files, I put the focus ...
musava_ribica's user avatar
1 vote
0 answers
46 views

JavaScript: Retry wrapper for the fetch-API

I know there are many good libraries for this, but to understand the issue better, here is my own basic attempt. The fetch will be retried if it fails with a promise rejection or the response ...
Amaterasu's user avatar
  • 205
0 votes
1 answer
59 views

Manage repetitive/similar structures (logging & try/catch blocks)

I'm writing a web bot using puppeteer and I'm logging (using winston) every action the bots does and running it inside try/catch blocks. For automating these processes and avoid code repetition I ...
lapdoggo's user avatar
1 vote
0 answers
42 views

Pulse effect on event driven architecture

Event driven architecture implementation resembling pulsing with configurable softness (intense, mild, subtle), pulsing mode (inhale, exhale), pulsing frequency (plain, dense, breathe), number of ...
user avatar
0 votes
0 answers
30 views

Bidirectional typing effect

Implementation supporting both typing directions from left to right and from right to left. It also supports alternating typing directions and configurable letter spacing. With monospace font the ...
user avatar
0 votes
0 answers
47 views

Ascend animation followed by hover effect

This CSS code creates an animation that describes a random movement using the CSS transition property for box-shadow which ...
user avatar
0 votes
0 answers
31 views

Colorproof dust effect (second thought)

The colorproof dust effect could be enhanced with positionproof feature getting the position of the dusted element (dust container) from its getBoundingClientRect ...
user avatar
2 votes
0 answers
148 views

Optimizing Performance of Minimum Translation Vector (MTV) Calculation in SAT Collisions

I've implemented a Collison Manager using the Separating Axis Theorem (SAT), and I'm looking for suggestions to enhance the performance of the Minimum Translation Vector (MTV) calculation. The ...
Mark Vaaz's user avatar
2 votes
0 answers
34 views

Colorproof dust effect

A combination of various css transitions (background-color, box-shadow, opacity, ...
user avatar
0 votes
1 answer
73 views

A Chrome extension for analytics debugging: code to render the popup

I made an extension and got it to the point where it does what I want how I want. At this point, I have a little capacity to work on code refactoring, readability and such. And I would love some ...
BNazaruk's user avatar
  • 117
2 votes
1 answer
100 views

Consuming sharded database using node.js

I think the only big improvement that can be made is to check which shard to query based on the userIds of the followed users. One easy way is to check the last ...
Sayaman's user avatar
  • 415
5 votes
2 answers
111 views

Seeded PRNG in JavaScript and Python yielding same results

So I need a PRNG in Python and JavaScript that yields the same results, which is the reason I can't use the built-in methods. It doesn't have to be very good or even cryptographically secure, since it'...
Amaterasu's user avatar
  • 205
1 vote
0 answers
24 views

InlineWorker class to implement a fancy inline dedicated worker

In my deep dive into the study of workers I started trying to create a worker that could run on the same file but return values from the sent function. Something like this but more sophisticated. <...
Leonardo Rick's user avatar
3 votes
1 answer
125 views

Handwriting progressive drawing

Implementation to progressively draw symbols, when provided with symbol implementations it supports any type of symbols, though for the review purpose just two hand written latin symbols are supported ...
user avatar
-1 votes
2 answers
50 views

I would like to horizontally align a HTML element to a specific place in the document [closed]

How can I horizontally align one HTML element to one elsewhere in the document? I came up with this solution aligning “aligned text” with “| text after alignment”, but I think that it is not good ...
matj1's user avatar
  • 9
1 vote
2 answers
176 views

Virtual scroller Vue component

Problem The scrolling looks smooth on Windows, but very laggy on Linux (Webkit webview and Webkit browsers). Any thoughts on what could be optimized or what's obviously broken? Demo playground: https:/...
AlekseyHoffman's user avatar
0 votes
0 answers
32 views

Calendar Grid with layering of multiple events

My attempt at coding an adjusting calendar grid. It seems to work in most cases I've tried (although I haven't tested it exhaustively yet) but my DOM is a bit rusty and I wonder if there's better ways ...
Mark Green's user avatar
1 vote
0 answers
44 views

Node.js Image Optimization Service Using Sharp Library

I've developed an image optimization service in Node.js, leveraging the Sharp library for image processing. The service is designed to handle various image formats, offering resizing and format ...
David Chochol's user avatar
2 votes
1 answer
173 views

auto image slider in js and css

I was just wanting a code review on this image slider I made. I don't have anyone else to give me their opinion on the code I write outside of work, so I'm asking here. okay so i had made an image ...
hestia's user avatar
  • 21
5 votes
1 answer
184 views

Tic-tac-toe with JS

I am a beginner and was hoping for some honest feedback on my js code. I struggled quite a bit on this, I did ask gpt to explain some concepts which I find it’s good for but wrote it all myself. <...
FeDev's user avatar
  • 61

1
2 3 4 5
191