Skip to main content

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
5 votes
2 answers
557 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
-1 votes
1 answer
86 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
118 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
74 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
32 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
  • 581
2 votes
1 answer
125 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
  • 49
1 vote
2 answers
159 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
139 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
115 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
  • 49
4 votes
1 answer
186 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
  • 451
1 vote
1 answer
42 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
47 views

weekly calendar date algorithm

...
user avatar
2 votes
0 answers
73 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
440 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
264 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
260 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
35 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
48 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
56 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
67 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
49 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
33 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
55 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
38 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
181 views

Optimizing Performance of 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
40 views

Colorproof dust effect

A combination of various css transitions (background-color, box-shadow, opacity, ...
user avatar
0 votes
1 answer
77 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
108 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 ...
user avatar
5 votes
2 answers
112 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
27 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
129 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
54 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
  • 109
1 vote
2 answers
182 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
36 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
53 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
276 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
211 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
3 votes
2 answers
67 views

Paragraph structure template generator refactoring

This is an app that generates random statement types, and basic conjunctions. How to improve its readability and function? How to deploy this code app online? This is the GitHub repository: https://...
Attila Vajda's user avatar
0 votes
0 answers
29 views

Video resumer web extension

made a Firefox extension for resuming videos, because on Firefox Android, YouTube videos that have been out of focus for a while, reset their playing time. There already exists a firefox extension for ...
hanshenrik's user avatar
1 vote
3 answers
332 views

programmatically update a <td> element per table row

A table that gets updated with new values as soon as they arrive. Each value is in its own row: An array of objects representing each a quote (ticker and price) ...
dhiaagr's user avatar
  • 65
4 votes
0 answers
91 views

Complete html5 platform game as a snippet

I made a complete little platformer game as a code snippet. The goal is to try to keep jumping on the enemies without touching the ground to increase score. I used Tad's Basic Game Objects, an open ...
mrall's user avatar
  • 41
1 vote
1 answer
59 views

How to encapsulated javascript code using imutable method?

I have this code, but I need to return pure functions instead the mutating functions. Is it possible? Perhaps using OOP? I don't know how to improve it. I tried to return the values in each function, ...
Wesley Souza's user avatar
0 votes
1 answer
98 views

Advent of Code 2023 day 1: Trebuchet in JS, part 2

The task involves analyzing a bunch of lines containing lines of text. Each line represents a calibration value that needs to be recovered by extracting the first and last digits and combining them ...
konijn's user avatar
  • 33.2k
2 votes
1 answer
73 views

Advent of Code 2023 day 1: Trebuchet in JS

The task involves analyzing a bunch of lines containing lines of text. Each line represents a calibration value that needs to be recovered by extracting the first and last digits and combining them ...
konijn's user avatar
  • 33.2k
1 vote
1 answer
72 views

String represents a road. One character travels on the road obeying the stops - Code challenge (advent.js day 5)

This is my code to solve the 5th Adventjs challenge. In that link you can read the instructions. How can I improve it? It's a bit messy... and I'm repeating some part of the code. All must be in just ...
Sofia Chardin's user avatar
4 votes
1 answer
85 views

access arrow data

I am fetching arrow tabular data from an API. The content-type of the response is application/vnd.apache.arrow.stream. In my react code, I am trying to read the ...
Deb's user avatar
  • 41
2 votes
1 answer
100 views

Move timestamp to the next Monday 10:01 AM [closed]

I've been battling ChatGPT for hours now and can't get satisfied with this simple algorithm in TypeScript. These two (hopefully correct) TypeScript+ReactNative solutions should move the timestamp ...
Slazer's user avatar
  • 121
1 vote
2 answers
157 views

Rubik's cube scrambler with timer and list of solves

This is a work in progress Rubik's Cube scramble generator with timer and list of solves. The list of solves is stored using localstorage so that it stays on page reload. A solve can also be deleted ...
HTMLNerd_1's user avatar
2 votes
1 answer
119 views

My code.org Game Lab project is running really slowly, how can I optimize the code further?

I'm working on my final project, and it is a game made with Java Script in code.org's Game Lab. The code worked fine, and it was not slow at all, but as I worked on it, it became much slower! The ...
Renier Jr.'s user avatar