All Questions
9,398 questions
6
votes
1
answer
152
views
Timezone-based VPN-detection
I use the following snippet at my browser homepage to detect whether or not I have VPN turned on. If the IP timezone is different from the browser timezone, then it is most probably VPN is turned on.
...
-5
votes
0
answers
30
views
Avoid duplicate if checks when overriding a method in JavaScript? [closed]
I have the following parent class method in JavaScript:
...
5
votes
1
answer
117
views
Cryptographically secure random int in range
I tried to make a cryptographically secure random int in range generator for javascript, practically the javascript equivalent of php's random_int(min,max):
...
5
votes
1
answer
169
views
Code to generate an array of 364 random special characters with 20 random words broken up throughout
I am trying to recreate a Fallout 4 style terminal hacking game, so I wanted to create code to generate the terminal output (namely, 32 rows with 12 characters each and 20 random words spread out). ...
1
vote
1
answer
53
views
Figure/number to text converter Javascript implementation: my take in Dutch: v2
I did a second version for my original question:
The original question
The reason I ask this question is I was trying to answer a question from a different user:
Figure/number to text converter ...
1
vote
2
answers
79
views
Figure/number to text converter javascript implementation (turn around)
A turned around, starting from units digit, reimplementation of Figure/number to text converter javascript implementation (second thought) started by Figure/number to text converter javascript ...
2
votes
1
answer
114
views
Figure/number to text converter Javascript implementation: my take in Dutch: v1
I read this question Figure/number to text converter javascript implementation. Like the answer said, that version has two main issues. I tried to solve them.
The main issues with the original:
The ...
5
votes
1
answer
114
views
Support Captain Picker in Vanilla JavaScript
I have been tinkering about a program that would pick the support "captain" of the day on workdays with the following rules:
Program should only pick a captain on weekdays (Mon. to Fri.).
...
5
votes
1
answer
89
views
Code for smart CSS rounding using JavaScript
I wrote a project that allows you to make CSS corner rounding more consistent and, in my opinion, nicer. Here's full GIT repo with an example and a README.md: https:...
5
votes
1
answer
513
views
Better way to share JavaScript code [closed]
I am working on a website using .NET Razor Pages. I have multiple pages that share JavaScript code. I'm using vanilla JavaScript. I have to perform actions related to mapping using leaflet. Most of ...
2
votes
1
answer
82
views
Merge discrete integer intervals
What it does
The code starts with a set of integer intervals, and can add new intervals (possibly by updating existing intervals). Essentially, it is a bit array whose index starts at ...
2
votes
1
answer
73
views
Figure/number to text converter javascript implementation
Developed around chain of responsibilities design pattern, it consists of a series of converters returning arrays of string that could be used either to look up text mapped to the keys, for ...
3
votes
2
answers
155
views
Basic Linked List Implementation in JavaScript
Clarification of Intent
Recursion here is used on purpose for practice - note that iteration is preferred in this case (I'll be more clear about where my intentions are!)
Factory function was also ...
2
votes
1
answer
339
views
HTML Editor: Online HTML Editor with Real-Time Preview
Overview
HTML Editor is a web-based HTML editor designed for web developers, designers, and learners. It offers a lightweight, minimalist environment for writing and previewing HTML, CSS, and ...
9
votes
2
answers
1k
views
Rock paper scissor game in Javascript
I am new to Javascript, and I made a simple Rock Paper scissor game with some basic UI. We can play the game for how much longer we want and can check the score of both computer and our. It's a ...
4
votes
5
answers
285
views
Gomoku game 5 in a row. Javascript simple game Canvas
Gomoku ★★★ (Tic Tac Toe)
There are many Gomoku (5 in a row) game projects on the Internet.
The scripts of these projects are freely available. Having analyzed them, I created my own
game code based on ...
2
votes
2
answers
133
views
Faster regex to match all worded numbers from 1 to 99
I would like to know if there is a better regex to match all worded numbers from 1 to 99.
With "better" I mean shorter with same performance, OR faster.
I came up with this. I can't do ...
5
votes
1
answer
121
views
Generate a Penrose tiling
I would like to know if it's possible to optimize the code the generate this type of Penrose Tiling.
I finished programming this type in javascript / p5.js and the algorithm works very fine and takes ...
7
votes
2
answers
300
views
Library project - javascript
I am going through the Odin Project and have just finished the 'Library' project on their FullStack JavaScript course. As this is the first time I'll have my code reviewed, I want to know what I'm ...
2
votes
2
answers
79
views
Optimize Working Live Search & Highlight Function
I've written a custom Live Search & Highlight function in vanilla JS. It is working and does what I expect it to.
The issue is that the more items I add to the page content to search, the slower ...
0
votes
0
answers
20
views
4
votes
3
answers
111
views
How to optimize the algorithm of generating images in javascript canvas?
I added this question on Stackoverflow, but it was suggested that I post it here.
Currently, I create 2000x2000 pixels canvas and tile the image on it, and then tiling the texture on top and applying <...
3
votes
1
answer
43
views
My surrealdb (1.x) migration script
I'm working on a migration script for surrealdb (currently working with 1.x).
Please review and let me know what I should improve.
...
2
votes
3
answers
193
views
Efficiently tagging first and last of each object matching condition
How can I make the code more readable and more efficient? (provided code is O(n²) time, but intuition says it can be pre-processed and done in O(n) time)
Description
it tags the first and last of ...
4
votes
1
answer
377
views
Tic Tac Toe with only the 3 last moves
I wrote a Tic-Tac-Toe game that unlike the normal TTT only saves the last 3 moves. That means, that the first move will be removed on the 4th move and so on.
To not necessarily extend the description ...
-2
votes
1
answer
97
views
Clicker game feedback [closed]
Can someone please look at my clicker game and tell me if it is good and what to add?
...
1
vote
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 ...
4
votes
1
answer
455
views
HTML Editor, Online HTML Editor with Real-Time Preview
Note
Please review the new question and ignore the following.
Overview
HTML Editor is a web-based HTML editor designed for web developers, designers, and learners. It offers a light-weight, ...
5
votes
2
answers
356
views
Full Promise implementation
I have attempted to implement the native Promise object provided by the browser in JavaScript. The code is pretty easy to understand. It supports most of the promise functionalities, such as chaining, ...
6
votes
2
answers
741
views
Lotto Number Generator - Javascript
Newbie to Javascript here and just practicing by making a random Lottery number generator. I am practicing by building simple, achievable projects.
The aim of this project is to make 10 lines of 6 ...
0
votes
2
answers
75
views
Showing the even numbers between two numbers which the user has entered
I've done it to be honest, but I feel like I'm writing extra code. I want a shortcut.
The code is:
...
1
vote
2
answers
143
views
JavaScript Fifteen
Made fifteen in JavaScript. I would like JavaScript programmers to point out my mistakes.
My code works fine. I made fifteen using a two-dimensional array and a one-dimensional array. The function for ...
3
votes
1
answer
395
views
Event sourcing javascript implementation
An event source built around an observer design pattern implementation…
...
7
votes
4
answers
867
views
ES6 inner join equivalent
Using the sample data from here, I'm attempting to write JS code (to the ES6 standard) that is equivalent to an SQL inner join. The solution below works fine, but it seems rather long. Is there a ...
1
vote
1
answer
120
views
Javascript Signals implementation
I've created my own implementation of signals in typescript, inspired by the proposed tc39 specification (https://github.com/tc39/proposal-signals) in the BOM. I think it would be great if I could use ...
1
vote
2
answers
109
views
A simple performant factorial function
I am new to algorithm and data structure. After a little introduction to the topic, I have decided to implement a function called calculateFactorial, which takes an integer and calculates its ...
6
votes
5
answers
477
views
Fill missing data in between available data with default value
My raw data has values on some random times:
const rawData = [
{hour: 3, value: 3} ,
{hour: 5, value: 9} ,
{hour: 10, value: 5} ,
] as const
I would like to ...
1
vote
1
answer
162
views
A web page for running AI vs. AI Connect Four matches with selection of algorithms and search depths
This time, I have prepared this page where a user may select what AI bots will be run in the game of Connect Four. The entire repository is here.
Code
index.html:
<...
1
vote
1
answer
66
views
Buffered source of HTMLElement(s)
Temporary storing the element(s) returned by document.querySelector and document.querySelectorAll methods could improve ...
3
votes
1
answer
96
views
Plain JavaScript Rock, Paper, Scissors
As part of "The Odin Project" web-dev curriculum, I created a simple "Rock, Paper, Scissors" game. I am hoping to receive feedback on how readable the code is and if the ...
4
votes
2
answers
992
views
another Tic-Tac-Toe Game
I have a bit of experience in programming but not that much. I was trying to create a TicTacToe Game in Javascript. I was doing my best to have a good structure. I was thinking about using classes, ...
3
votes
3
answers
150
views
Efficiently generate a random position inside an outer rectangle but outside an inner rectangle
It should be a uniform distribution (ie: every point is equally as likely). I also don't want to use the simple solution of: "in a loop check to see if the current generated point is within the ...
3
votes
1
answer
47
views
Seeking help for spreadsheet script for making it compact (date recovery from serialnumbers script)
I wrote some working code in spreadsheet scripts, but it's a little bulky and slow. Is there any way to refactor this to be more compact and faster?
I'm a beginner, so I'm happy it works at the moment....
4
votes
1
answer
99
views
Page scroll marker user script
I recently recalled having a "scroll mark" feature, that is, a line that would show up when hitting the space bar in the Opera browser? There used to be a Greasemonkey script for Firefox, ...
4
votes
1
answer
595
views
HTML Editor : online HTML editor with real-time preview
Note
Please review the new question and ignore the following.
Overview
HTML Editor is an online HTML editor with a minimalist approach. Edit your HTML, CSS, and JavaScript code and monitor the ...
5
votes
2
answers
667
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 ...
1
vote
2
answers
58
views
Calculating the total value of an invoice with precision
I have written some functions to calculate the total cost of an invoice, gives its line items. Could someone please tell me if there seems to be a problem with the code? Since it is something as ...
1
vote
1
answer
73
views
Extract each occurrence from an array of objects
I have a huge list of 4k+ software products.
My goal is simple. I have a list of products. Each of those products has a software value. I would like to extract each software occurrence and covert it ...
3
votes
2
answers
94
views
Optimizing a Function to Check Pronic Numbers in JavaScript
I've written a function in JavaScript to check whether a given number is a Pronic number. A Pronic number, also known as an oblong number, rectangular number, or ...
1
vote
1
answer
54
views
Negamax AI for playing Connect Four against Alpha-beta pruning AI in Javascript
The working page is in GitHub.
Introduction
This time, I have two AI bots playing Connect Four against each other. The first AI bot uses Alpha-beta pruning, and the other one uses a Negamax with Alpha-...