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
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 <...
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 ...
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 ...
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 ...
5 votes
1 answer
2k views

JavaScript implementation of Pascal's Triangle

I'm currently trying to teach myself JavaScript. If someone could critique my implementation of Pascal's Triangle I would be very grateful. ...
4 votes
2 answers
5k views

Laravel 8 registration and login with user profiles

I am working on a Laravel application (Github repo) that requires user registration and login. After registration, the users can change their registration details (except password, for which there is ...
0 votes
0 answers
3k views

TypingTest Autotyper Userscript

For fun, I decided to inspect the obfuscated source code on TypingTest and figure out how to write an auto typer for it. I came up with the following UserScript. A couple of notes: The site's code ...
10 votes
1 answer
258 views

Chart showing the Percentage of Answered CR questions

Every day Duga reports the number of unanswered questions and percentage of answered questions (after she calls the API endpoint /info) in The 2nd Monitor. I ...
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 ...
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 ...
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
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: ...
5 votes
1 answer
103 views

Secure password generator form

With the demise of passwordsgenerator.net I wrote my own generator; Please review with an eye on correctness and maintainability; ...
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 ...
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, ...
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 ...
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
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 ...
4 votes
4 answers
2k views

Simple login script with sha256 hashing

I have been using this code for a while. I got it from a tutorial 5 years back. Now I'm wondering if it still is secure, or if it's time to find a new one? Maybe it has never been secure enough. ...
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
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, ...
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
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 ...
4 votes
1 answer
448 views

Credit card number formatter

How to make my script shorter and better? This code allows only digits, auto-format card number like this XXXX XXXX XXXX XXXX. If the user hits delete or backspace to delete space in between digits, ...
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 ...
2 votes
1 answer
132 views

Ecommerce site shipping data

I have a REST API using the Laravel framework and the front-end uses the Vue.js framework. It is a dashboard for an e-commerce store where you can connect to a post shipment service API to upload ...
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: <...
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) ...
3 votes
1 answer
395 views

Event sourcing javascript implementation

An event source built around an observer design pattern implementation… ...
7 votes
1 answer
369 views

Working with images in multiple formats

I've been doing some research around how to best make use of the WebP images (with fallback) in React. Most solutions point to something similar to what I've written below. That means if I have a lot ...
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
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: ...
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 ...
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 ...
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 ...
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 ...
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 ...
8 votes
2 answers
350 views

Usability of API to declare modules in JavaScript

As a JavaScript developer, I want to write modules in a format that is well supported today and that will still work in five years. I designed an open-source library to this end, scope or not, with ...
15 votes
5 answers
2k views

Javascript Syntax-Highlighter for Java

Project I wanted to create a syntax highlighter for Java using JavaScript, HTML and CSS. It uses regular expressions to find the parts that should be highlighted (at the moment: keywords, strings, ...
9 votes
2 answers
338 views

Follow-up: Javascript Syntax-Highlighter for Java

Background The basics of this project have already been discussed here. I've improved the following things: Sᴀᴍ Onᴇᴌᴀ mentioned that I shouldn't use multiple elements with the same id. I corrected ...
0 votes
0 answers
38 views

Sparkling effect

Developed around hls() CSS function and anchor tag wrapping elements with display CSS property set to ...
12 votes
1 answer
471 views

Resizable containers with VueJS

A month ago I reviewed the code in Resizable split DIVs Vue.js, suggesting that the OP use computed properties and bound styles to simplify the code (at least reducing the need to use ...
21 votes
6 answers
4k views

Find the longest word's length

The challenge is simple: Return the length of the longest word in the provided sentence. The solution is just as simple: ...
1 vote
1 answer
80 views

Sprinkler effect

Developed around visibility CSS property and HTMLElement#offsetHeight and ...
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
1 answer
43 views

simple express api for temperature conversion

...

1
2 3 4 5
190