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):
...
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 ...
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). ...
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 ...
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 ...
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.).
...
0
votes
0
answers
20
views
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 ...
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:...
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
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.
...
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
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 ...
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
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?
...
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 ...
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 <...
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
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 ...
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:
...
2
votes
1
answer
340
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 ...
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 ...
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 ...
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 ...
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 ...
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....
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 ...
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, ...
3
votes
1
answer
395
views
Event sourcing javascript implementation
An event source built around an observer design pattern implementation…
...
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 ...
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
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:
<...
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, ...
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 ...
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-...
2
votes
0
answers
47
views
Connect Four AI vs. AI match in Javascript
This time, I have a Javascript program that runs a Connect Four match between two Alpha-beta pruning based AI bots. (See this page.)
ai-battle.html:
...
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, ...
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
1
answer
56
views
Creating an API secured only by the request signature
I'm trying to create an API that will receive requests from users without having to do a login request. They will just have a user id and a key. My intention is that they will use the key to create a ...
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 ...
1
vote
0
answers
87
views
comment-monk - Comment hosting script for static blogs and websites
So few days ago, I had created another review request for sqlite database schema for a comment hosting system.
Now that the app development is complete, I have pushed the initial version on github. As ...
2
votes
1
answer
58
views
Combining multiple regexps using the `|` operator and grouping the regexps by their flags
I've implemented a function that creates a multiple regular expressions predicate. The idea behind the predicate is combining regular expressions using the disjunction operator ...
1
vote
1
answer
55
views
Listening to bootstrap 5 events in a vuejs application
Starting out with VueJS, making a small fun project. The project is a simple static portfolio website, with a navigation bar at the top and a bootstrap scrollspy, jumping to the different sections (I ...
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 ...
1
vote
1
answer
81
views
Sprinkler effect
Developed around visibility CSS property and HTMLElement#offsetHeight and ...
3
votes
1
answer
45
views