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
0
votes
1
answer
93
views
Create and store the level data for a remake of Super Mario Bros game
I am trying to remake Super Mario Bros. in JavaScript and I am trying to figure out if there is a more efficient/shorter way to create and store the level data. I have created 1-1 and here's what the ...
1
vote
1
answer
116
views
Personal Computer Web-surfing Digital Well being user script
I have written the following JavaScript small script to do three things in a web browser:
Block all or most News websites (send your browser to google.com instead)
Block automatic playing of any ...
3
votes
1
answer
497
views
Accurate countdown timer
I modified a code from for an accurate timer from Stack Overflow to create a countdown timer:
...
1
vote
0
answers
39
views
Tampermonkey Note Taker for Google Docs: Version 2
First version of code here: Tampermonkey Note Taker for Google Docs.
I think I have made it better by splitting on the "StorageInterface".
Code
...
2
votes
0
answers
184
views
Tampermonkey Note Taker for Google Docs
Intro:
Need some feeback on my Javascript (I mostly do C++).
Purpose: I find google docs hard to organize in google drive (it takes more effort than it should).
So I started created "note" ...
2
votes
2
answers
194
views
First app with JS in OOP
I've already started to creating apps in JS with OOP.
I made simple TicTacToe Game in OOP and I want to ask you to review my code and point out everything that I can change about OOP. What is bad ...
1
vote
1
answer
59
views
String iteration algorithms performance in jQuery Terminal
I have a JavaScript library jQuery Terminal and I have internal formatting that is used to change colors and style of the text that look like this:
...
0
votes
2
answers
75
views
Palindrome test in JavaScript function
I hope you will tell me tips to ask good questions regarding checking my code. Here it's the code and thanks in advance!
...
4
votes
1
answer
191
views
Hangman Game in HTML + CSS + JS
I recently developed a hangman game with HTML, CSS and JavaScript and I would like to get your feedback and tips to improve it. The goal of the game is to guess a secret word before 6 incorrect ...
2
votes
1
answer
126
views
4
votes
1
answer
886
views
Rock, paper, scissors with HTML & CSS & JS
I started studying web development a few months ago and to practice my skills I decided to do the game of rock, paper, scissors.
Here are some questions for review:
Is the use of HTML semantics ...
3
votes
1
answer
283
views
JSON comparison function
I've written a comparison function between two json values. I'd like to know if it can be improved at all in any way. Thanks again for the help.
...
1
vote
0
answers
23
views
Designing a font definition with multiple variants per glyph
My project penhand tries to visualize the process of writing with a pen. Part of the project is an engine that converts text entry into a sequence of glyphs that are then rendered as animation into a ...
1
vote
1
answer
128
views
Form Validation Code Optimization in HTML and JavaScript"
I've been working on a simple form validation code in JavaScript coupled with an HTML form. The form asks for user's basic information, including name, email, country, gender, and skills. There's a ...
6
votes
1
answer
1k
views
Username Validation RegExp
Working through the freeCodeCamp JavaScript curriculum and I found this RegExp task surprisingly tricky (maybe I just don't use RegExp very much).
The parameters are:
Usernames can only use alpha-...
1
vote
1
answer
351
views
Movies App with Vue 3 and TypeScript
I have made a Movies App with Vue 3, TypeScript and The Movie Database (TMDB) API. For aesthetics, I rely on Bootstrap 5.
In src\App.vue I have:
...
6
votes
4
answers
769
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
0
answers
56
views
extracting values from an array of nested objects without duplicates
I have my solution for the below usecase but I would like to know whether is any other effective solution for the same.
My Data:
...
0
votes
1
answer
2k
views
Encrypt and decrypt text using 256-bit AES-GCM
I'm working on building an encrypt/decrypt feature using AES, and a fixed AES 256-bit key size. I have decided on using AES-GCM, as it seems the most performant and secure.
I would like to know ...
1
vote
0
answers
34
views
Asynchronous Generic Resource Pooler
A personal project I'm working on needs Worker (thread) pool. The libraries I looked at were too high-level for my needs, as I simply needed access to the Worker itself while the libraries offered ...
3
votes
1
answer
155
views
JavaScript seedable Math.random
I made an implementation of xoshiro256** in JavaScript, using BigInts. It's designed to mimic Math.random. Any feedback on the code quality?
...
-2
votes
2
answers
100
views
Is this a good way to advance one-by-one in an array of objects? [closed]
Using plain JavaScript, I want to load an array of objects, display the first one in a Bootstrap Card, and then click a button to advance to the next one. Focusing only on the point of getting the ...
3
votes
2
answers
325
views
Count matching pairs (modular equality)
Problem
Given an array of natural numbers a. Find the number of such pairs of elements (a_i, a_j), where ...
0
votes
1
answer
216
views
2
votes
2
answers
68
views
Given a sorted list of integers, find the highest count of elements between an indeterminate but fixed size range
I'm trying to optimize a function that takes a sorted list of integers and tells me what is the maximum number of elements in the list between any definite size range. To be clear, the range itself ...
1
vote
1
answer
335
views
Im trying to show the traffic lights in a loop
I am trying to build this:
Build a traffic light where the lights switch from green to yellow to red after predetermined intervals and loop indefinitely. Each light should be lit for the following ...
4
votes
1
answer
111
views
Legend of Zelda: Breath of the Wild armor upgrade materials tracker
There are plenty of these online already but none of them quite fit what I wanted. I've been meaning to learn some more front-end stuff so I decided to make one myself. I know some JavaScript but ...
2
votes
1
answer
71
views
Automatically extract useful cars from car site
I am using puppeteer to extract data and see when a car that meets my requirements shows up, this is what I did so far. I would like some basic syntax advice, or more advanced tips as well.
I tried to ...
3
votes
0
answers
41
views
Cross-classification of imagery from several regions in GEE
For a project I want to do the following:
Use imagery from 17 different regions in Europe to train 17 RF classifiers
Use those 17 classifiers to classify each of the regions
It will be a multi-...
5
votes
2
answers
2k
views
SHA-256 Hash with a short string length in javascript
I think I've found a way to somewhat "compress" the length of a SHA-256 hash. I am doing some addition, so I wanted to know whether an approach like this is secure or not.
...
5
votes
0
answers
508
views
Implementing a Basic Camera UI using WebGPU and JavaScript
Context
I am currently in the process of throwing myself into learning graphics programming, and my chosen platform is using JavaScript and WebGPU. After successfully making a basic glTF JSON renderer ...
0
votes
1
answer
142
views
Generate HTML from input fields
I am building a small tool to generate a copy and paste HTML block, based on the user inputs.
In the HTML file, I have all my inputs (select, checkbox, text inputs etc).
I based myself on the JS of an ...
1
vote
0
answers
66
views
DOM manipulating that I called Framework
I'm building a framework like this that can turn SASS-like code into CSS, a template engine like Mustache, a DOM manipulator like React, and a router to add a single page app, and I'm having a ...
2
votes
2
answers
334
views
Find Free Appointment Slots given Opening Times and Booked Appointment Times
Any ideas to make it better or more efficient? any edge cases that are not covered?
Opening times:
...
6
votes
1
answer
433
views
Minesweeper game implementation in (vanilla) JS
I decided to write my own version of a Mine Sweeper game as an excuse for a Javascript/HTML/CSS project. Just to make the question self-contained: Mine Sweeper is a game with a rectangular board ...
0
votes
3
answers
63
views
function to get title from result object depending on if title is empty [closed]
I want to rewrite if else statements with something nicer or refactor the code i have to something neat using javascript.
below is the code,
...
5
votes
2
answers
640
views
Display properties of a country, from online service
I'm currently learning Vue JS and I made a simple app that pulls information from API and displays facts about a country given a 2-letter country code. I'm looking for feedback on how to improve the ...
0
votes
1
answer
33
views
Choose a marker for the map based on the alerts it has
I need help to refactor this code, I think I can avoid the first two functions that filter the array. Also in the third part where I use the result of these two filters:
...
2
votes
2
answers
202
views
Text input with currency icon in the center
I want to have a input element for currency where there is a currency icon always at the center (but it adjusts according to the number of digits)
Something like:
This is what I've come up with:
<...
0
votes
0
answers
15
views
Batch Loading data for Deep Learning
Context
Just for learning purposes and using asynchronous iterators, I am creating a data loader that could be useful for machine learning especially images. Tensorflow has a similar function I think, ...
1
vote
2
answers
578
views
Split the Bill and calculate the Tip
I have created a Bill Splitter page that asks for the total bill amount, tip percentage, and the number of people. Then it displays the tip and the total amount (including the tip) each person has to ...
1
vote
0
answers
47
views
Enable a textbox when the previous one is no longer empty
I've written this JavaScript code, which disables textboxes if the previous textbox is empty. This is so people enter the text in order — write first in the first textbox, only then the second textbox ...
1
vote
1
answer
79
views
Improving player button control code
Would somebody be kind enough to show me the best way to loop through this so it much more efficient that just repeating everything?
...
4
votes
1
answer
94
views
Refactoring duplicate validation by array column wise
I am creating a functions to validate the array's duplicate by column wise from the given array. it works. Any one help me to minimize my code:
...
1
vote
1
answer
158
views
Simple calculator project
This code displays a simple decimal calculator with operations like add, subtract, multiply and divide. It also has a function to clear the result.
I try to reduce code repetition. I still think I ...
0
votes
1
answer
140
views
Separate a list in two lists using JavaScript
I have a list of events. They are html elements.
The premium events have a data attribute in their parent element: data-premium-event.
I need to separate the events in two lists:
a list of premium ...
0
votes
2
answers
124
views
Create an array which contains one object per objectid
Is there a better or simplified approach to create an array which contains one object per objectid with an array of contacts that matches globalLkupRemoveContactReviewer by userid and then send each ...
0
votes
1
answer
125
views
Using JavaScript to interface with REST APIs
The website TryHackMe came up with a challenge that involves using HTTP requests to interface with REST APIs (here, task #14/day 9). The challenge basically involves querying a basic REST API to ...
0
votes
1
answer
252
views
code to format text input to 2 decimal places before computation
I have this piece of code that checks the input of a text box before I compute for my main logic. This looks like it should be refactored but I'm currently stumped how to do so. The only thing that ...
3
votes
0
answers
90
views
Speed up a JavaScript function for inverting matrices using Gauss elimination
I wrote this function and I'm interested if it can be sped up by improving the code.
The function accepts either column major 1D array or 2D row major array.
Maybe there are some obvious JS tricks ...