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.

894 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6 votes
0 answers
586 views

nodejs 401 request retry mechanism

I'm working on a project in which I have a backend in nodejs and from there I need to call external APIs, those APIs require authentication token which is valid for 15 minutes. So if response status ...
Abhay Sehgal's user avatar
5 votes
0 answers
508 views

Implementing a Basic Camera UI using WebGPU and JavaScript

Context I am currently in the process of throwing myself into learning graphics programming, and my chosen platform is using JavaScript and WebGPU. After successfully making a basic glTF JSON renderer ...
user2628206's user avatar
5 votes
0 answers
114 views

Created a paperfold like effect

I am trying to recreate a neat effect that I saw posted on Stack Overflow as a GIF . I am trying to recreate this with CSS and JavaScript and I have created a similar effect with a button press. I ...
Nico Shultz's user avatar
5 votes
0 answers
568 views

React Context & Hooks custom Vuex like store

I've been experimenting with Hooks lately and looking more into how can I replace Redux with useContext and useReduer. For me, ...
htmn's user avatar
  • 218
5 votes
0 answers
217 views

A generic DFS in JavaScript

I implemented a general function for a depth-first-search (DFS) using JavaScript with default arguments and functions that need to be provided in order for it to work. This function is using ...
Evgeny Zislis's user avatar
5 votes
0 answers
238 views

Spacial hashing Library

Old code ...
Tobi's user avatar
  • 241
5 votes
0 answers
176 views

Assembling and traversing a graph, given a list of items and parent pointers

I've written a function which takes input such as this: ...
Tomáš Hübelbauer's user avatar
5 votes
0 answers
779 views

Hunt n' Kill algorithm

Last day I implemented the Hunt and Kill algorithm in JavaScript, using HTML5 without any libraries. I would like my code to be reviewed. How it works I start with a 2D array filled with walls (1-s),...
Bálint's user avatar
  • 321
5 votes
0 answers
3k views

Finding all paths between nodes in a graph

I wanted to write a function paths that returns the possible routes between two nodes in a graph. For example: ...
52d6c6af's user avatar
  • 672
5 votes
0 answers
5k views

Todo list with calendar

The app is a todo list with a three-day calendar. Users can add and remove lists and it's all stored in local storage. My aim was to use vanilla JS but I did use jQuery for the date picker. I'm just ...
monkeyman905's user avatar
5 votes
0 answers
85 views

Using components instead controllers in EmberJS v2

I am beginner in EmberJS. I have made todomvc for ember v2 for learning Ember. My implementation works without controller. I use components instead controllers. In the documentation I see: ...
izumeroot's user avatar
  • 151
5 votes
0 answers
1k views

Mocking the file system within a test

I've been using this method to test file-system functions as an alternative to mock-fs due to its lack of symlink support. I'd love to hear what others think and ...
ThomasReggi's user avatar
5 votes
1 answer
4k views

Largest rectangle areas after drawing boundaries

I was asked the following question while trying to get a Hackerrank certificate. I couldn't solve on time but I now completed the solution. Can you please check if my solution seems good? Suggestions ...
Benny Joo'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
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
4 votes
0 answers
182 views

Optimizing a Wordle Solver in JavaScript

I have written a Wordle solver in JavaScript. The solver generates a decision tree. For each word, it generates all possible feedbacks patterns for that word, it then selects for each pattern the word ...
Cortex's user avatar
  • 440
4 votes
0 answers
149 views

Find the longest "common sequence" in two lists

In short, the algorithm must find the longest sequence that joins together common sequences from two lists (a more formal specification is given in the code's header). The lists are assumed to contain ...
user266319's user avatar
4 votes
0 answers
212 views

GeekTrust: Traffic problem - functional programming

First attempt to write functional programming, been following OO paradigm all through my programming journey Please review the code and let me know if any comments and violations of functional ...
HariHaravelan's user avatar
4 votes
0 answers
54 views

Fetching data from endpoint, retrieving coordinates, then merging into an output

I'm in no way a skilled developer (or even a developer at that!) but I did want to take a go at writing a script that fetched one endpoint's data, extracted some data, sent if off to be geocoded, then ...
markb's user avatar
  • 171
4 votes
0 answers
63 views

Javascript portfolio with 11 small apps

I'm learning to code for about a year and recently I finished my Javascript project. It contains of 11 fairly simple apps involving using APIs and DOM manipulations https://github.com/matt765/js it's ...
Johnny92's user avatar
4 votes
0 answers
53 views

Todolist in vanillaJS

I have been studying front-end development for 2 .5 months, I decided to switch to practice and wrote a todo list in 8 hours Please write your opinion about the code and how it can be improved (...
Ivan's user avatar
  • 41
4 votes
0 answers
1k views

Jest - mocking a class function from an external node module

I am writing unit tests for a NestJS service, which imports and instantiates a class (OAuth2Client) from an external module (google-auth-library) and uses one of its functions (verifyIdToken). I am ...
hero121's user avatar
  • 41
4 votes
0 answers
74 views

Looking for feedback on a simple finite state machine for logging in with xstate

I have a sample React app that loads a username and password, and then randomly provides a login result on submission for the sake of example. CodeSandbox: https://codesandbox.io/s/stack-xstate-login-...
Harley Lang's user avatar
4 votes
0 answers
40 views

Rearranging data from one table to another in spreadsheets using apps script

I need some help with making my code run faster. It currently works by going through all cells in a 201x151 table. If the value in a cell is not equal to zero, then it will return the row number, the ...
MRuba's user avatar
  • 41
4 votes
0 answers
53 views

Generating rooted labelled subtrees of a JS object

I recently had cause to write some code which would take an object like const obj = { a: 1, c: { d: 1, e: 1 } }; Which we ...
Countingstuff's user avatar
4 votes
0 answers
56 views

How to split and refactor a large function so it would do only one thing?

I am learning about clean and maintainable code. I heard that functions should be no more than 20 lines long (preferably 5 - 10 lines). I have come across this Bob Martin quote where he said: “The ...
Liga's user avatar
  • 141
4 votes
0 answers
1k views

RxJS - Prevent valueChange of one form control if another form group is dirty OR an HTTP error has occurred

I've recently started working on an Angular 7 project (I'm pretty new to Angular and RxJS), and I was requested to implement this new functionality: The Problem I have to implement a component to ...
user avatar
4 votes
0 answers
164 views

HSL Guessing Game in Svelte

The objective of the game is to guess the hue, saturation, and lightness values of a given color swatch across ten rounds. https://github.com/shreyasminocha/guess-the-hsl https://guess-the-hsl.now.sh ...
shreyasminocha's user avatar
4 votes
0 answers
342 views

JavaScript AVL Tree

I have been working through Introduction to Algorithms 3rd Edition, and have implemented an AVL tree through prototypal inheritance. The code presented here does work as expected based on the tests ...
Evan Bechtol's user avatar
  • 1,255
4 votes
0 answers
53 views

Browser and Node.js compatible code require

The Reason The reason I designed this code was that in many cases, when I wanted to test code in the browser that would be running on a Node instance, the code that I was copying (Don't worry, copying ...
FreezePhoenix's user avatar
4 votes
0 answers
550 views

RxJs memoized singleton selectors

I am working on an angular stack that has n amount of services that hold data in stores of this type: ...
Lars Holdaas's user avatar
4 votes
0 answers
331 views

Running a JavaScript program from C# with sandboxing

I am using EdgeJS in my application. The application is used to run a user-provided javascript program from C#. Because we allow execution of user scripts some sandboxing is required. I am using vm2 ...
Aashish Upadhyay's user avatar
4 votes
0 answers
411 views

MongoDB BulkWrite - create or update a sub document within an array

I have a series of Events (roughly 10-20 events that will be dynamically created per month): Event Model: ...
Matt Carlotta's user avatar
4 votes
0 answers
886 views

Node JS | From Excel to Json

Intro -> I have to convert an excel file, which comes usually in this way: to a Json file that must looks like this: ...
Matteo's user avatar
  • 41
4 votes
0 answers
180 views

Vuejs - input validation

I'm in a project that's currently using vue. I'm at the moment developing validations for the inputs and in a way to make them more flexible, my idea was to create an intermediate component "...
martinho's user avatar
  • 161
4 votes
0 answers
175 views

Node.js tool to update Cisco UCCX with CSV data

What this tool does update skills for agents on a Contact Center Cluster (Cisco UCCX). The tool reads a csv file called agents.csv from the current working directory. This file has a list of agents ...
Mr Wannabe's user avatar
4 votes
0 answers
104 views

Formatting CSV as a table using BDD

This is the problem: Write a function to create a table from CSV data. The input to the function is a list of strings. Each string is formatted as a CSV record. Here’s an example for a ...
Boolood's user avatar
  • 41
4 votes
0 answers
468 views

Chess AI Using Minimax and Alpha-Beta Pruning

I am working on a Chess AI using chess.js, and currently, it can run 3 layers in under 10 seconds, but 4 or more takes minutes. How can I optimize my current code to be able to run 4 or 5 layers, or ...
CannotCode's user avatar
4 votes
0 answers
403 views

Get current user middleware from JWT using express

I'm using Sequelize and Google oAuth for authentication, I want to create a middleware that Verifies the sent token passed in the headers matches the one the user was initially signed to. Finds the ...
CarlosG90's user avatar
4 votes
0 answers
1k views

Block YouTube iframes until user consents with cookies

I'm trying to embed YouTube video's on a website in a privacy-friendly way. The code doesn't load the iframes by default but shows a preview thumbnail overlayed with an info message instead. The ...
TheDancingCode's user avatar
4 votes
0 answers
622 views

Client-side routing using Knockout and HTML5 History API for a single-page web application

The full question is... "Please, how can this code base or project (for client-side routing using Knockout and HTML5 History API) be further enhanced as regards security, production-readiness, ES6, ...
Olumide's user avatar
  • 141
4 votes
0 answers
136 views

All the paths from the root to the leaves

Given a binary tree, return all root-to-leaf paths. Example: -- 1 / \ 2 3 \ 5 Output should be: ["1->2->5", "1->3"] My approach: I walk the branches ...
Rick's user avatar
  • 586
4 votes
0 answers
79 views

JavaScript attempt at an aspect oriented logger using proxies and reflect

I've been playing around with AOP in JavaScript to create a Logger that I can attach to classes and output what is going on (mainly instantiation, calling of functions and the results from functions). ...
Jarede's user avatar
  • 309
4 votes
0 answers
46 views

Parsing root-level elements out of HTML fragment file

I have the following code written in NodeJS, using the parse5 library. It's purpose is to parse out the root-level elements in a file containing HTML fragments (Vue ...
threed's user avatar
  • 181
4 votes
0 answers
103 views

UI testing for a web application, with variant scenarios

I'm pretty new to software testing and am currently working on a cloud-based web application. Briefly, the application uses: Ext JS as a framework Bryntum's Siesta framework for testing Currently, ...
Nuri Engin's user avatar
4 votes
0 answers
57 views

Showing a Wikipedia article's changes as Git commits

I created a small-ish NodeJS script which takes as argument the name of a Wikipedia article (and optionally a Wikipedia edition, "en" is default) and creates a Git repository with each change made to ...
Bruno Pérel's user avatar
4 votes
0 answers
293 views

React.js defaultMemoize as container

this is the code I wrote ...
Anup's user avatar
  • 141
4 votes
0 answers
706 views

Generating Bitly links in a Google Sheet

I have this set of functions in my Google Sheet to create a Bitly bitlink whenever data in a row is changed. While this does work, it seems really slow to me. Looking at the Execution transcript, it ...
Jon Bourne's user avatar
4 votes
0 answers
314 views

Parsing BibTeX in JavaScript

I have a project for which I need to parse BibTeX strings. In v0.2.9 and before, I used Regex, and I want to change that. I set up a while loop system that reads ...
LarsW's user avatar
  • 141
4 votes
0 answers
237 views

Extensible factory method for starting D3 charts

I'm working on refactoring some existing code to be a bit more extensible and am wanting to create a generic factory API for starting D3 charts. Currently, my factory looks like this: ...
aendra's user avatar
  • 141

1
2 3 4 5
18