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
0answers
8 views

React native I have multiple useEffect, listeners or handlers of service but in the same component

please help me with this question please i have multiple useEffect and handler of services like subscriptions, listener of network state, listener of state of redux, and other things the component ...
-2
votes
2answers
86 views

Write conditional expression better [closed]

I have the following code function x () { return a ? (b ? 'result1' : 'result2') : 'result1'; } Is there a better way to combine these two conditions into one?...
-1
votes
0answers
18 views

Vue JS - Error : Property 'xxxx' does not exist on type <component-name> [closed]

I'm new to vue, So, to describe my work: I implemented a form and bound it to the data() hooks to retrieve the data from the from, and then onSubmit() I create an object newClass{} and $emit it to ...
3
votes
2answers
46 views

Retry a callback function n times until success

I want to make a function to retry calling callback n times until it return TRUE; Here's my current code: ...
0
votes
0answers
30 views

Synchronous Lock system with asynchronous methods

I needed a way to ensure that a function called was done only one at a time. Because of how Javascript is done and with Asynchronous functions, this wasn't the case, and there could be concurrency ...
1
vote
0answers
24 views

Embedded Timer Explorer

This is a toy design analysis utility meant to support decisions around configuring a timer on a microcontroller. The initial configuration is an example meant to partially represent the possible ...
0
votes
1answer
12 views

UserScript to navigate to the next comic page on 8 Bit Theater by clicking on the panel on the current page

I wrote this UserScript for personal use to allow me to click the main comic panel in order to navigate to the next panel, a feature which I consider essential for any webcomic, to the point that ...
2
votes
0answers
50 views

express.js server to resize images

What I have is a simple express js server where user sends an image url with a specific width all in the URL query. the code will get the image stream pipe it into a sharp.js module then send it back. ...
0
votes
4answers
157 views

High CPU and memory usage iterating over 300K objects

I am trying to run a series of keywords against a series of categories and then within those categories there are some options. So I have ended up doing a forEach ...
0
votes
0answers
19 views

Finding what carousel slides have to be cloned in order to mimic infinite scrolling

The code below finds what carousel slides have to be cloned in order to mimic infinite scrolling. It starts at one end of the existing slides indexes and then tries to create an "infinite" ...
3
votes
1answer
81 views

Javascript array from IP address

I want to make this code better. It works now but I think it can be better. I have a working sample on jsfiddle. When the page loads I have the End IP Address disable until the data is entered. Then I ...
3
votes
1answer
106 views

Remove unwanted characters at the end of a string

I want to make this code better , its works now, but i think it can be better , i have a hook and one property is onChange that get value and can setState and return that value for value of input , in ...
1
vote
1answer
38 views

How to exclude elements from an array based on a Map while maintaining O(n)?

I am trying to exclude some elements from array items that include properties from array excludes. I wrote this code which works ...
2
votes
2answers
20 views

Transforming a data of key value pairs to label and key

I have the following data ...
3
votes
2answers
77 views

Filter an object array based on certain conditions

How can I rewrite this in a cleaner way? I have this function that takes a list of contacts of different types (are being called ...
0
votes
0answers
25 views

Should I replace this request queue?

I just found myself hacking around the limitations of a backend that aborts highly concurrent transactions by queueing the requests using Solution A. I don't like this solution very much, and have a ...
3
votes
0answers
36 views

Sneakers store UI challenge

So I have been coding for just under 6 months now. I've made many projects but I don't have a clue if I am writing good code. So I did this frontendmentor challenge which includes HTML CSS and JS. It'...
0
votes
1answer
33 views

An if statment which check access to a specific feature based on specific cases

In my React application, I had to add an if statement to check for specific access requirements to a specific feature. This access is determined by the roles, actions, and features. I created an if ...
0
votes
0answers
35 views

Don't Upload Existing Images in React

I have successfully filtered images that are existing in React. My problem is I wanted to improve or use the latest JavaScript on this particular code below where it filters the images. How do I ...
2
votes
1answer
18 views

Implementation of a schema-less `AND` query in Node.js against array of objects

Note: I'm still very new to the code-review stack exchange, so if this question does not align with the community guidelines please leave a comment below explaining and I will do my best to modify it ...
1
vote
0answers
49 views

Algorithm to fit people in a monthly calendar

I have an interesting algorithm to build and I have tried a couple of things but couldn't get it just right. I have the following set of rules: 16 people to fill every day of the month (let's call it ...
0
votes
0answers
16 views

make an array of cells from formula like in excel with javascript?

I'm working on stylesheet in Excel, and I've made this function of makeCells is there a better way of doing it. I've tried regex to get two cells ...
2
votes
0answers
30 views

Numbering sidebar elements based on start/finish variables

I've created a numbering system that compliments another javascript library for numbering documentation. I know this can be done in CSS but because this gets rendered and outputted as static HTML ...
0
votes
0answers
14 views

Google Chrome Service Worker Persistent Storage Caching System

Moving from Google Chrome Extensions’ Manifest V2 to Manifest V3, service workers replace background pages. Background pages can be configured to be persistent, but service workers can’t be persistent....
1
vote
0answers
37 views

Better way to make an hamburger menu responsive

I'm trying to make a responsive hamburger menu for a project that has been assigned to me. I've (kinda) managed to do it, but I don't actually know if the way I reached it is the proper one. What I'm ...
0
votes
2answers
94 views

Vue 3 audio player

I have been working on an audio player with Vue 3 and the Napster API. ...
2
votes
1answer
43 views

Exponentiate common factors with JavaScript

I've created a function that exponentiates common factors. I'd like to optimize/simplify it because, as you can see, it's very messy and not very performant ...
4
votes
4answers
206 views

Finding duplicates in an array of objects

Hope everyone is having a good Christmas. First of all, this is working code in a production environment. I recently wrote some code for work. The goal is to find ...
1
vote
2answers
97 views

group countries by language in JavaScript

I need a better implementation than the below code (O(N) Solution), I am grouping countries by language ( data ) is the countries JSON, each country could have 0, 1 .. or more language as the object ...
0
votes
1answer
35 views

Storing information in a bad way using localstorage?

As I am a new programmer, it is very often that I find features of JavaScript that aren't any good, or I am not using them well. I recently discovered a module for storing data called ...
2
votes
3answers
52 views

Javascript date / time display

I'm writing a simple start page and it's my first time with JavaScript, my previous background is Python/VBScript. Is it good enough? What best practices should I apply? Should I compress and nest the ...
0
votes
2answers
36 views

url encoding and storing (JS, PHP, MySQL)

This question is about how best to encode, send and store information between JavaScript, PHP, and MySQL I am doing a GET request from HTML/JavaScript to my PHP server, which is then storing the data ...
1
vote
1answer
61 views

One-time password verification

I've built a small OTP code verification component and I need reviews and suggestion to improve its performance and maybe the logic behind it. The purpose is to publish my first 'react component' to ...
0
votes
1answer
26 views

Sanitize object to only include specific properties

Object Property Sanitization I'm learning to code servers using JavaScript, Node, and Express. While writing controllers that create new entries in the database, the need to sanitize the user input ...
2
votes
2answers
89 views

Sorting table rows visually with animation while keeping them intact in the DOM

I have a table which i want to sort the rows visually according to a column while the rows remain intact in the DOM structure. So nodes aren't moving in the DOM or getting replaced with eachother at ...
1
vote
1answer
28 views

Show selected person in another panel

I was playing with JavaScript in order to practice and wanted to make a list of people, which when clicked showed the person's details in another part of the screen. Here's the code I used to ...
4
votes
3answers
165 views

Add missing business days in CSV file

I need to fill missing business days (i.e. any days except saturday and sunday) in a series. So let's say I have this array: ...
0
votes
1answer
26 views

Gradient with interactive background

I'm coding this starry background for a website using p5.js, and it has 3 elements: There is a background that slowly intervals between black and white. This is ...
-1
votes
1answer
185 views

A New Sorting Algorithm

I have designed an Algorithm for sorting numbers. This algorithm works by sorting an array of any length with random, non-repeating whole numbers in a linear manner by ascending order. Under the ...
0
votes
0answers
18 views

Simple full page multi-step form. (Minus the form) using jQuery

I've tried my hand at creating a simple multistep system for a form. I used this CodePen as a base. I'm not too Jquery savvy so I'm thinking there could be smarter ways to accomplish what I have done, ...
6
votes
1answer
144 views

Implementation of exponential backoff algorithm

You can read about the algorithm here. An exponential backoff algorithm retries requests exponentially, increasing the waiting time between retries up to a maximum backoff time. An example is: Make ...
3
votes
1answer
38 views

Updating Default Player Stats on Load

I'm a self taught hobbyist programmer, for what it's worth. My latest project is a JavaScript based choose your own adventure game using Twine (Tweego) as the framework. If you're not familiar with ...
4
votes
1answer
40 views

Four HTML tabs elements, with fade animations, activated by buttons

I am pretty new to Javascript and trying to make a really simple tabs element which is just hiding and showing sections depending on which button is clicked. I know that this is a terrible way of ...
1
vote
0answers
30 views

A simple recipe page in HTML, SASS and JS

I've been learning how to design responsive webpages. I got done the basics and can create code that closely resembles the design, but I was wondering what are the best practices in web development ...
1
vote
0answers
50 views

Split columns moving in the opposite direction when scrolled - in a continuous loop

I've seen something similar and have been trying to refactor the JS. I have two columns of content, which when scrolled move in opposite directions. This should also loop continuously. The ...
2
votes
2answers
76 views

Grade Calculator Tool Code Improvement

I am just looking for code improvements as I believe that it is done, and would like to see it expanded. I mainly want code improvements to make it more efficient, but any and all constructive ...
2
votes
0answers
31 views

Create a more efficient and performant csv import function with Python Django

I am creating a website for users to track their Magic the Gathering inventory. I have created some functionality to import a csv to easily add cards to their inventory. The functionality works as ...
0
votes
1answer
34 views

React async useEffect with loading and error state

This is my first time trying to add clean error handling and loading notification for async requests in my project. It looks kind of bulky to me, but maybe that's because I'm inexperienced? This is ...
1
vote
1answer
25 views

Utilizing <template> or DocumentFragment in an appropriate manner

I wrote this code, it actually works, and I'm going to use this strategy in an active project that's due in January. I don't know web components yet -- the best I can personally utilize is ...
0
votes
1answer
30 views

URL redirection via cookie parsing

I'm attempting to look at a portion of a cookie's value, and if it contains 'en_us', do one thing, and if it contains 'es_us', ...

1
2 3 4 5
191