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.
9,486
questions
4
votes
3
answers
88
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
3
answers
201
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
182
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
65
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:
...
0
votes
0
answers
150
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 light-weight, 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
290
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
140
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
358
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
113
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
346
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 ...
0
votes
0
answers
38
views
injecting the laravel debugbar into a VueJS app served via vue-cli-service
My team develops an app with an API using the Laravel framework and the front-end is developed with VueJS. Locally vue-cli-service serve (a wrapper around Webpack) ...
1
vote
2
answers
55
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 ...
0
votes
1
answer
151
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
98
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
92
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 ...
0
votes
1
answer
53
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
45
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
442
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
66
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
50
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
739
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
84
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
55
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
47
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 ...
0
votes
0
answers
38
views
Sparkling effect
Developed around hls() CSS function and anchor tag wrapping elements with display CSS property set to ...
3
votes
3
answers
144
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
80
views
Sprinkler effect
Developed around visibility CSS property and HTMLElement#offsetHeight and ...
3
votes
1
answer
43
views
1
vote
1
answer
76
views
Calculate Prime Number using web workers and Web storage in HTML5
Take a number input (less than 100) from the user and save it to the web storage. Create a web worker to increment the number till it becomes prime. Provide two buttons of 'Start' and 'End' to start ...
3
votes
2
answers
97
views
A rock-paper-scissors game using HTML & Javascript
I have created a pretty simple rock-paper-scissors game that uses event listeners and manipulates the DOM. I would appreciate any constructive feedback. Whether it is readability, variable names, ...
3
votes
2
answers
92
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 ...
3
votes
2
answers
58
views
Optimizing a Function to Generate a Row of Consecutive Odd Numbers in a Triangle
I've written a JavaScript function that generates a row of consecutive odd numbers in a triangle. The triangle looks like this:
...
4
votes
1
answer
592
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 ...
0
votes
0
answers
45
views
Convert CSS-styled HTML to Word file without a server
I am building a non-jQuery port of jQuery-Word-Export, which is to my knowledge the best tool to convert CSS-styled HTML to a file that can be opened, edited, and saved on Microsoft Word (Windows and ...
0
votes
0
answers
38
views
How can I make the webRTC and signaling feature code production ready?
I am learning webRTC and tried to implement signaling service through websockets. I am still a beginner in backend development so not sure how correct my code is. Can you please review it and let me ...
6
votes
5
answers
473
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 ...
4
votes
1
answer
94
views
rock paper scissors game in console
I've made a simple rock paper scissors game using javascript. Any feedback appreciated. This is a first project I've done with almost no help
...
4
votes
3
answers
174
views
Get the contents of a table cell for all selected rows
I have a table of user info. When you click the button, I want to get the email address from each selected row, output into a comma-separated string.
I got it to work with the following code, but I'm ...
7
votes
4
answers
859
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 ...
0
votes
1
answer
77
views
Raw HTTP header parser
The code must produce the desired output
Input
...
0
votes
0
answers
46
views
Testing whether parenthesis are correct in a string in functional JS
This is a homework exercise and therefore has no further purpose. The writing to me feels clunky, and the typescript types on addParenthesisFactory are unreadable, ...
0
votes
0
answers
60
views
The Wacky World of ANSI Escape Sequences?
I just finished creating my first npm package (for learning, not competition) and published it. Now I want to ask some questions, for example:
Is my method of writing code good (for later maintenance ...
3
votes
1
answer
99
views
CPU emulation library
I've started to work on a JavaScript library called vCPU with the purpose of providing a framework for emulators. vCPU is designed to be able to emulate multiple types of CPUs, with setup only ...
4
votes
1
answer
123
views
Hangman game in JavaScript
I have attempted to create a hangman game in JavaScript. Some parts of my code is a bit DRY. Basically, the Hangman class is a wrapper for all of the available actions in a typical hangman game: setup ...
5
votes
2
answers
985
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, ...