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
0 votes
3 answers
133 views

A Tic Tac Toe Game Made With Javascript

I just finished creating a Tic Tac Toe game in Javascript, but now am wondering if there are ways I could improve upon the code I've written for it. Mind the lack of CSS here. ...
Delfino's user avatar
  • 509
1 vote
0 answers
76 views

Variable button increment picked from an input:range in React 18

I'm a newbye in React. I created some simple Components to practice. For now, I'm using class Component (I want learn either class COmponent or function COmponent). I would know if I projected ...
Nick's user avatar
  • 111
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
1 vote
1 answer
191 views

Is this string-comparison function safe against timing attacks?

Here's a JavaScript function that check the equality of input and secret strings, trying to do that without leaking information ...
Azerum's user avatar
  • 123
1 vote
1 answer
78 views

Tracking people's check-in and check-out at an event

I have some logic that helps me calculate the data for a summary of an event, which should be rendered as something like this: ...
Andrey Namikaze's user avatar
3 votes
1 answer
255 views

Find the closest named color

I have a .json file with name (string) and RGB (r, g, b: numbers) with 30.000 key-value pairs. I am looping the json multiple times per second to find the closest name to a given RGB color. Any idea ...
Relik8's user avatar
  • 31
2 votes
1 answer
58 views

JS animated string builder

Today, I tried to write a simple function that would display the characters of my string one by one by iterating over a string containing the letters of the alphabet and showing the steps on the ...
Luca Natale's user avatar
0 votes
1 answer
196 views

Listener for property value changes in a Javascript object

The purpose of this code is add proxy on nested object for log changes on property. This is a debug utility! ...
Simone Nigro's user avatar
2 votes
1 answer
149 views

Simple JS Password System

I created a simple password system using HTML, CSS, and JS to quiz myself on my variable, localstorage, and if and else ...
HTMLNerd_1's user avatar
4 votes
1 answer
527 views

calculate the number of ways to pick two different indices

I'm working on a codesignal practice problem You are given an array of integers a and an integer k. Your task is to calculate the number of ways to pick two different indices i < j, such that a[i] ...
Josh's user avatar
  • 41
2 votes
2 answers
112 views

Merge three (or more) arrays based on specific index and create new array

I have three arrays in which first index is same, so I want to merge all three array into one array based on first index element Input: ...
Murtuza Z's user avatar
  • 121
0 votes
1 answer
264 views

Smart and Inututive Auto-Format Date Input

I'm developing a custom date input format to enhance user experience in scenarios where birthdays and expiration dates are inputted. Traditional date fields and date picker libraries often fall short ...
tony's user avatar
  • 383
2 votes
2 answers
311 views

Given an array, remove zero or more elements to maximize the reduction where you add odd values and subtract even values

Here's a code challenge I got. (I could not solve the challenge, I ran out of time. I rephrased the challenge language and I am trying the challenge again for personal growth & computer science ...
Nate Anderson's user avatar
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
3 votes
2 answers
121 views

The core of the assembler (the part of the assembler that actually converts mnemonics to opcodes) is hard to follow due to many if-branchings

For my Bachelor thesis, I made a PicoBlaze Assembler and Emulator in JavaScript. I've discussed it on many Internet forums, and quite a few people have complained that the core of my assembler is hard-...
FlatAssembler's user avatar
2 votes
2 answers
72 views

French Republican Calendar Converter (Romme Rule)

This is a French Republican Calendar / Gregorian Calendar converter I've written; it returns an accurate date for all the dates I've tested (mostly dates in the present age, although it also lines up ...
lagomorph's user avatar
4 votes
1 answer
157 views

Convert durations to a single unit

In the codebase I inherited, I have this function which converts a number and unit into milliseconds: ...
LocustHorde's user avatar
5 votes
1 answer
222 views

v-for loop generating list items that will get rearranged based on an associated value (ranking system)

A counter gets incremented by a custom value. Each increment value gets stored with its refcount that tracks how many times it occurred. An ordered list shows all increment values entered so far by ...
dhiaagr's user avatar
  • 65
2 votes
2 answers
72 views

Calculating the sum of all k-sized sub-arrays in an array using sliding window algorithm

I need to calculate the sum of all k-sized sub-arrays in an array using sliding window algorithm. Is that a valid sliding window algorithm? If not, why? ...
Alekam's user avatar
  • 21
3 votes
1 answer
237 views

Modernized Javascript randomULID() Generator - Smaller and Optimized

I've finally finished these 2 scripts and would like to get some feedback. Seeking feedback on a modernized ULID (Universally Unique Lexicographically Sortable Identifier) generator in Javascript. ...
suchislife's user avatar
1 vote
2 answers
145 views

Receiving a daily reward

I'm doing a daily reward system on my site. Users can pick up the reward only once a day. The next reward can be picked up the next day, also, only once. When a user visits the site to pick up a daily ...
Andrew Ourst's user avatar
1 vote
1 answer
76 views

Javascript CLI to boot iOS simulators, install project, extract data, and merge into JSON

I'm a DIY "dev" - so I really create things that I need or think they'll end up helping others. I wrote this Swift Package so the iOS community could get device bezel radius' to help with UI ...
markb's user avatar
  • 171
2 votes
1 answer
73 views

Reorganice (and style) form's output in HTML using JQuery: how to do it better?

To clarify: The code in "What I achieved" is working. I'm looking for suggestions so I can improve. I'm quite new with JQuery (and javascript) and I've been learning while styling a forum. ...
Lucas's user avatar
  • 21
2 votes
2 answers
220 views

Permissions system in MERN app

I am working on a MERN stack app that is a CRM with a couple of modules. Now when the user sends x request to the server to do a supposed action (such as delete something), the server first checks if ...
Syed M. Sannan's user avatar
0 votes
1 answer
73 views

Handling pure in browser HTTP request in Service Worker fetch event

I was suggested by @Bergi on StackOverflow that Async Promise constructors are any pattern. The argument behind this is that async Promise swallows the errors. In my case, I have try..catch so I'm not ...
jcubic's user avatar
  • 238
2 votes
1 answer
104 views

An extended JavaScript plugin for rendering radial pie charts

(This post is the continuation of A JavaScript plugin for rendering radial pie charts.) (See the continuation of this post.) Now, you can mark up the radial pie charts via XML: ...
coderodde's user avatar
  • 29.1k
1 vote
1 answer
65 views

Observer design pattern: value observer and variable observer implementation

Observer implementation that leverages both behaviours observing a variable and observing for a value. Supports subscribing and withdrawing observers. ...
user avatar
3 votes
1 answer
93 views

A JavaScript plugin for rendering radial pie charts

(See also An extended JavaScript plugin for rendering radial pie charts.) I have this JavaScript plugin: rodde-radial-pie-chart.js: ...
coderodde's user avatar
  • 29.1k
2 votes
0 answers
80 views

Javascript basic search engine recipes

I have made a search engine for recipes. Requirements for this JS Project are as follow: Create a function called searchRecipes that takes all recipes and an ...
Yass's user avatar
  • 21
0 votes
1 answer
44 views

js template engine

I am building a template engine for js and I need some help refactoring the code for fast and more efficient performance. If you can help modify or suggest some updates I'll be grateful. ...
ahmed qoreichi's user avatar
3 votes
2 answers
99 views

Solving round number in JS by using String

Whatever language you choose, you may encounter a rounding problem. In fact, this is due to the limit of the required number of bits needed to get the right number after a calculation. Simple example: ...
Sébastien Josserand's user avatar
2 votes
0 answers
110 views

Create a Penrose tiling

I programmed this type of Penrose Tilings in javascript and the algorithm is 'simple': The cyan pentagon always have to draw the yellow losenge and the grey pentagon almost always have to draw two red ...
visionary's user avatar
4 votes
1 answer
52 views

JavaScript search algorithm to find a town in a particular state

I built a function in JavaScript which executes a search algorithm to find a town in a particular state. The dataset, referenced by the variable townsAndStates is ...
code writer 3000's user avatar
0 votes
1 answer
217 views

Random number generator

Util functions to generate random numbers with upper bound or with both upper and lower bounds: ...
user avatar
5 votes
1 answer
135 views

Partial Function Application in JavaScript

I'm trying to make a partial function from any function. Here is a working example: ...
Miroslav Popov's user avatar
2 votes
1 answer
81 views

Session-based authentication using Express.js

I'm currently learning Express.js and I wrote this authentication code. I'm unsure if what i have is correct, how to improve it and if it's secure. For user and session data storage I'm using ...
Krneki123's user avatar
1 vote
0 answers
69 views

Calculate total running time for movie series

Which of these 2 functions is better and more readable and why? (Both functions do the same thing). My goal is to get the total time of a series, using the TMDB API (which has a limit of 20 different ...
jofyavoydo's user avatar
1 vote
1 answer
54 views

Click temporization on user interface elements

Implementation to accommodate different behaviours based on the frequency a user interface element is clicked. It supports number of clicks and number of clicks in a time frame. ...
user275176's user avatar
3 votes
1 answer
97 views

JavaScript front-end 'Library App' implementation from the Odin project

I am currently working through the Javascript portion of the Odin Project curriculum and have completed the library app project. As far as I can see everything is working as expected and I have ...
Daria's user avatar
  • 33
1 vote
2 answers
78 views

Changing every link on page, in fastest way possible

I have created a script (mediawiki gadget), which iterates over every redlink in a rendered wiki-page (that is, over every href with class new, signifying an ...
philo math's user avatar
1 vote
1 answer
750 views

Minesweeper game with HTML & CSS & JavaScript

I made a Minesweeper game using HTML, CSS and JavaScript and would like to ask for advice and feedback specifically on the code. Here are some questions to review: Is the use of HTML semantics ...
Lucio Mazzini's user avatar
1 vote
0 answers
54 views

Memory game code quality

I am making an incremental-memory-game similar to this https://www.crazygames.com/game/incremental-memory I am not very satisfied of how spaghetti this code is. I am trying to learn to improve my code ...
jerma lover1's user avatar
0 votes
0 answers
57 views

small app with bad practices on node.js and vue.js

Can someone help me to understand and give me code review of my small todos APP, why my code in backend is bad? Also give me a answers for some of my questions, please: Where my code is bad? Where do ...
Олег Лазорик's user avatar
0 votes
2 answers
170 views

jQuery + PHP Form Submit and Refresh

Code below successfully processes and submits data to database. Is there anything else that needs to be included / considered? PHP (note-process.php): ...
Matt's user avatar
  • 9
1 vote
1 answer
252 views

Calorie Calculator

I have developed a calorie-tracker webpage and would appreciate some feedback on it. I'm particularly interested in optimizing performance, improving code readability, and ensuring best practices are ...
Ultimate's user avatar
  • 143
3 votes
1 answer
266 views

Snake game using Canvas API

Edit 2: For anyone interested, you can play the game at buggysnake.com Edit 1: I have typed up the code for making the body of the snake move. It's not perfect and there are small problems I need to ...
Seeker's user avatar
  • 133
1 vote
2 answers
213 views

Function that formats number of seconds to total time (days, hours, minutes and seconds)

I need to format total number of seconds to total time in the following format: Days:Hours:Minutes:Seconds. This is what I did: ...
pileup's user avatar
  • 451
4 votes
2 answers
430 views

Detecting when a user stops typing

I wanted to detect when a user stops typing. I encountered this answer from SO (Not the selected answer, but the second one which seem to be better): https://stackoverflow.com/a/5926782/17746636 But I ...
pileup's user avatar
  • 451
0 votes
3 answers
80 views

Find an object based on substring value

...
user274262's user avatar
1 vote
0 answers
30 views

Storage manager which creates super simple API to talk with chrome storage

Here's some background information: I was working on a Chrome extension called Netflix Hotkeys (you can find it here), and I realized that I needed a persistent storage solution for storing user ...
Kunal Kamble's user avatar