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

Custom react dropdown

Last night I had to build dropdown for the menu on the website that I'm working on. As I'm still React newbie I first looked if there is some package for what I'm trying to achieve but there wasn't, ...
-6
votes
0answers
16 views

Component structure in vanilla js application [closed]

Github repo url: https://github.com/himanshu206/news Tried to write component structure in vanilla javascript Need inputs in this structuring of code Its just a dummy application ( emphasis on ...
1
vote
0answers
15 views

“Clean Architecture” design pattern with Node.JS and MongoDB

After some time poorly designing my web applications' backends (mixing database calls with the controller, etc.), I have decided to try the "Clean Architecture" approach. In this example I have a ...
-5
votes
0answers
12 views

jQuery get index of .active element, but with reference to its original siblings [closed]

I am toggling an active class to an object in jquery in a grid like so : ...
2
votes
1answer
43 views

Javascript - how can I increase the run speed of these loops

I am trying to solve this question: MaxCounters. Solving it is straightforward, but solving it fast enough is proving very difficult. How can I improve the performance of this code? At the moment it ...
0
votes
0answers
14 views

Vue.js in legacy web application

I'm working on modernizing legacy ASP.NET WebForms site which heavily relies on doing AJAX request for client-side rendering. Without the use of vue-cli compiling <...
2
votes
1answer
50 views

Leetcode Search in Rotated Sorted Array

I was doing Search in sorted array question from leetcode Question Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become ...
-3
votes
0answers
24 views

How to group an array of objects by key [closed]

What is the most efficient way to groupby objects in an array? ...
1
vote
0answers
10 views

Syncing Redux state with the URI in 2020

I have a React/Redux/Router/Reselect app in which I am syncing some parts of the redux state with the URL. As an interim, hacky measure (I've only been learning how to write wepapps for about 6 months ...
2
votes
0answers
35 views

Leetcode three sum in Javascript

I was doing 3sum question on leetcode Question Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the ...
0
votes
0answers
21 views

Todo app in React.js

I've built a simple todo app using React and it's really basic. However, before I continue to implement new functionality, I would like to check if everything is alright. ...
1
vote
0answers
36 views

Best Way to DownLoad File in JS

I want to download a file in js. I am doing this with the following code, but want this code to be better. Any good suggestion will be appreciated. ...
-4
votes
0answers
14 views

Layer re-ordering in fabricjs [closed]

I am trying to implement fabricjs ordering methods in my application. bringForward bringToFront sendToBack sendBackwards Problem: Ordering of objects works fine in the initial attempt but the ...
2
votes
1answer
34 views

Javascript - Extract data from html table

I want to extract the headers data and column data (not row data) from an HTML table using JavaScript. Is this a good approach of doing it? And how can I simplify this using jQuery? ...
3
votes
1answer
82 views

Simple todo list in Javascript [closed]

I'm looking for someone to tell me how I could refactor/change/improve my JS, I'm still learning and really want my code to be the best it can be for when it comes time for me getting a job in the ...
2
votes
1answer
25 views

How can I clean up (DRY) this verbose jQuery code?

I had posted this on StackOverflow — someone pointed me here. My code is working, but it's incredibly verbose and I know that it can be made more compact. I just don't know how :-) I'm building an ...
2
votes
1answer
24 views

Creating multiple DOM buttons in JavaScript (I am not DRYing)

I am making a Tic-tac-toe game and I have the basic board but I am repeating the code and it is very badly written. I am wondering how I can use better practices to write the DOM elements that I need. ...
2
votes
1answer
22 views

Draw element border according to scroll amount

I needed to draw border element according to scroll amount. I made it work but I am not sure about optimization and performance. There may have a better way? I am open to suggestion you can see it ...
2
votes
2answers
39 views

Filtering and adding additional properties to array of objects

Hi I am working on a complex application and currently adding two additional properties to objects that match the condition and returning it back. I was able to achieve the expected output, but just ...
0
votes
0answers
25 views

Scrape page and send user only new results

Review Wanted Application Summary The application is a simple screen scraper which is to notify the user when new items are posted. The code is run as a CRON job every ten minutes. It will scrape ...
4
votes
1answer
57 views

Delays using multiple for loops

I got this script which work perfectly but I got some delays because of this 2 for loops [i][j] is there any way to do the same ...
0
votes
0answers
12 views

Await all HTTP request body chunks before moving on

I'm developing a man-in-the-middle proxy that will let the user see and modify HTTP and HTTPS requests before they leave the client and responses before they arrive at the client. The code I'm working ...
1
vote
0answers
24 views

Mocha chai tests

I want to have a test fail, because the email already exists, so I create duplicate@dave.com and dave@dave.com, but is there a way to do it without this? ...
0
votes
0answers
12 views

Reactjs, control list of list of input

...
-2
votes
0answers
29 views

React - How to create a generic component & avoiding duplicate code

I create a website of images, using React. The data of each image received from Firebase. When the user clicks on a certain ...
3
votes
2answers
79 views

Efficiently generate large file to create SQL table and insert sample user data

Here's a function I use to generate a 2.5 gig SQL dump file for testing. It works but it takes a long time. How can I make it more efficient? ...
1
vote
2answers
41 views

Use proxy for jQuery-like DOM extensions

I have cleared all my scripting from the use of JQuery, but sometimes I miss a few handy extensions. Now I'm playing with the idea to "extend" ...
2
votes
1answer
33 views

Refactoring string incrementing and duplicating function

I wrote this script and got what I wanted from it. However I'm looking for input on ways I can improve the function. My goal was to scrape a bunch of image links from a website I'd like to rebuild. ...
1
vote
1answer
79 views

arithmetic with numbers and letters

I've started learning JavaScript last week. Today I ran into a JS exercise available at this link codewars exercise and decided to give it a try. I've used very basic JS because I know only a small ...
-2
votes
0answers
22 views

Changing html using .innerHTML where one half of new html is string and the other half is a number [closed]

I am new to web development and have been self teaching for 3 months. I am creating a webapp that helps budget income. I am at the stage where I ask the user to use my calculator to calculate annual ...
1
vote
1answer
32 views

Promise-based HTTP abstraction layer

I am currently working in a project based on a microservices architecture pattern. Services are wired up by HTTP calls. They eventually call each others for fetching or putting some data. I am ...
2
votes
1answer
25 views

Multi Selection Component with Filter (React + Hooks)

This component is meant to take in an array of available options and provide the user an easy way to choose multiple options and filter on the available options. Each time the selected options are ...
2
votes
0answers
20 views

HackerRank's Challenging Palindromes solution times out for certain tests

I am trying to solve the Challenging Palindromes problem from HackerRank. The code that I have got so far fails only for large inputs due to timeout, every other test it passes successfully. The ...
3
votes
2answers
74 views

Huffman Encoding in Javascript

So, I've implemented Huffman Encoding in JavaScript, you can see it live here. Here is the code: ...
-2
votes
0answers
12 views

(Javascript) Please check my code for Sudoku validation [closed]

I was working on this Codewar Kata called "did I finish my sudoku". I couldn't find any problems but apparently there is a bug somewhere. Can you help me find it please? ...
1
vote
0answers
27 views

Multi Selection Component (React + Hooks)

all. This component is meant to take in an array of available options and provide the user an easy way to choose multiple options. Each time the selected options are changed/updated, those options are ...
3
votes
1answer
54 views

Does my graphics engine code follow good conventions?

I am making a 2d graphics engine. I am somewhat new to JavaScript and have been winging this project. So far it creates a background (a tilemap made of smaller images in a grid) and sprites ( a small ...
1
vote
0answers
17 views

Modeling mongoose schemas

I'm in the process of creating my first web app using node with mongodb on the backend. I could use some opinions on the schemas/models I've set up. I have three schemas: User, Pet, Food. Here's the ...
1
vote
0answers
12 views

Custom Global Store using React.js context and hooks

I wanted to use an external global state to a React.js application with a redux-like sort of pattern (with reducers, actions, etc). However, I don't want to use redux itself, as it's just a small ...
5
votes
2answers
334 views

Parsing numbers and ranges from a string in Javascript

I would like to convert a string like "1 2 3-5" to an array of numbers [1, 2, 3, 4, 5]. Following the robustness principle, the ...
1
vote
1answer
53 views

Text notifications for Facebook Marketplace posting

Application Summary I received a call from a client asking for a "simple app" that notified him via text message whenever a "Jeep Wrangler" is posted to Facebook Marketplace. It sounded simple enough,...
3
votes
1answer
50 views

Bubble sort visualization: JavaScript

I'm very new to the JavaScript, and hence I would like to get a feel on the language by writing some of the basic programs. One of those is the following visualization of the Bubble Sort: Code: <...
1
vote
1answer
40 views

Generating a new web-page template and adding multiple new elements with pure JavaScript?

So, I am trying to generate a web-page template with JavaScript according to user specified values. I tested it with just background-color and made it working. I ...
1
vote
1answer
28 views

Displaying information from shops

To display all the shops, I get data from a database (Firestore) and push them into array and setState, and use map to display shops from ...
4
votes
1answer
54 views

Retrieving my public IP address with the javascript Fetch API (no jquery, no json)

Note for future reference and google searches The list of urls for IP retrieving will very likely need continuous adjustments in the future. ...
0
votes
1answer
43 views

Node refactor if/else mess

I'd love some pointers on how to refactor this ...
1
vote
0answers
23 views

Proxy server performance improvements?

fairly new to playing around with proxy servers. Wrote a really simple one with Express to help keep some API keys secret so that my front-end app can query the GitHub API. Definitely feels a bit ...
2
votes
1answer
57 views

Hackerrank problem -“Another Prime Problem”

I came across this issue in the problem titled: Another Prime Problem. Here's my solution with JavaScript which passed test case-1, but for other test cases it led to timeout. ...
4
votes
1answer
98 views

Access token regeneration for Axios requests

Description I've developed an application which use axios to communicate with the PayPal API. PayPal has a NodeJS SDK, but unfortunately this doesn't support the ...

1
2 3 4 5
173