All Questions
9,398 questions
0
votes
2
answers
171
views
jQuery + PHP Form Submit and Refresh
Code below successfully processes and submits data to database. Is there anything else that needs to be included / considered?
PHP (note-process.php):
...
10
votes
1
answer
3k
views
Check for balanced brackets in JavaScript
Rules: You should create a function that receives a string with brackets, parentheses, or curly brackets, an example:
test('{A}')
The function must check that the ...
13
votes
5
answers
3k
views
Vue.js search functionality
In my BlogList.vue component I made a search input field:
...
0
votes
1
answer
96
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 ...
3
votes
1
answer
501
views
Accurate countdown timer
I modified a code from for an accurate timer from Stack Overflow to create a countdown timer:
...
6
votes
1
answer
439
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 ...
11
votes
4
answers
3k
views
Restructuring JSON to create a new JSON where properties are grouped according to similar values
I have a JSON structure in the following example format:
...
1
vote
1
answer
337
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 ...
37
votes
5
answers
3k
views
When "How To Ask" is too subtle
This is the first JavaScript code I've ever written, alert("hello, world!"); aside.
This site is closing quite a lot of questions because people won't read the ...
16
votes
3
answers
2k
views
Convert camelCase and PascalCase to Title Case
I'm trying to take camelCase and PascalCase strings into a function and spit them out as Title Case. This function also needs to be able to handle odd PascalCase strings with capitalized abbreviations ...
5
votes
3
answers
293
views
Largest Triple Products without using sort?
I implemented the Largest Triple Products algorithm, but I use sort which makes my time complexity \$O(n *log(n))\$. Is there a way to implement it without a temporary sorted array?
The problem:
You'...
11
votes
5
answers
3k
views
A faster way to compute the largest prime factor
I am self-learning js and came across this problem(#3) from the Euler Project
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
...
4
votes
1
answer
453
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, ...
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!
...
126
votes
4
answers
25k
views
Celebratory fireworks animation
To celebrate an important event, I hastily cobbled together an HTML canvas-based animation.
A few concerns I have include:
Performance: Does it run reasonably smoothly on most modern machines? How ...
11
votes
3
answers
11k
views
Sum of all possible concatenations of array values
Given an array of non-negative integers, we need to find the sum of concatenation of elements in the array.
For example -
given [11, 22] the result should be - 6666
i.e.,
11 + 11 = 1111
11 + 22 = ...
43
votes
3
answers
44k
views
Partitioning an array based on a condition in Javascript
Using the array.filter function, I can efficiently pull out all elements that do or do not meet a condition:
...
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.
...
2
votes
1
answer
7k
views
Filtering array of nested objects
The following code is producing the desired output but I'm wondering if there's a way to accomplish the same result by applying .filter() to ...
13
votes
2
answers
2k
views
Stack Overflow clone
I have to write a simple web application using the Java Spring framework as my course project. So I decided to write a simple Stack Overflow clone. My application has the following features:
...
4
votes
2
answers
1k
views
JavaScript front end for Odin Project book library database
I am currently working on The Odin Project and have reached the JavaScript Part. There is a project, to create a Website that serves a a library. You can add a book and it appears on the site as a ...
0
votes
1
answer
127
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 ...
8
votes
4
answers
1k
views
Check if calendar week number falls within two other week numbers
I want to check with Javascript if a week number (with year) is within two other week numbers.
Example data: Year-Week ...
7
votes
3
answers
2k
views
Wordle color algorithm in JavaScript
A lot of Wordle clones get the tile-coloring algorithm wrong: for example,
if the word is BURNT and you guess TOAST, the colors should be ----G (not Y---G)
if the word is MAXIM and you guess MAMMA, ...
60
votes
5
answers
260k
views
String.IsNullOrEmpty in JavaScript
I am aware of it being frowned upon to do something like write C# in JavaScript. (see this if you don't know what I'm talking about)
But as a judgement call, I think we could stand to have a ...
2
votes
2
answers
263
views
React component which uses another component for rendering
Having this React component:
...
0
votes
3
answers
81
views
10
votes
6
answers
1k
views
Method to delegate command to other methods
Since I am working alone on this, I would like someone who would take a look and point out any mistakes or things I could have done better.
My questions:
How could I improve this big switch statement?...
1
vote
1
answer
763
views
Minesweeper game with HTML & CSS & JavaScript
I made a Minesweeper game using HTML, CSS and JavaScript and would like to ask for advice and feedback specifically on the code.
Here are some questions to review:
Is the use of HTML semantics ...
6
votes
2
answers
3k
views
Calculate sum of values from checkboxes
I have a bunch of checkboxes with a data-amount attribute containing a value (positive or negative).
My goal is to generate a running total as the user checks each ...
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
160
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 ...
2
votes
1
answer
129
views
4
votes
6
answers
1k
views
0
votes
1
answer
218
views
3
votes
1
answer
99
views
JavaScript front-end 'Library App' implementation from the Odin project
I am currently working through the Javascript portion of the Odin Project curriculum and have completed the library app project.
As far as I can see everything is working as expected and I have ...
2
votes
2
answers
69
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 ...
4
votes
2
answers
94
views
Vue.js - Sierpinski Triangle
Below is a Vue app I wrote to draw a Sierpinski Triangle given n iterations, which can be incremented/decremented via a HTML ...
-2
votes
2
answers
104
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 ...
2
votes
2
answers
336
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:
...
5
votes
0
answers
516
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 ...
3
votes
2
answers
298
views
Binary Expression Tree that evaluates Postfix input
My code for a Binary Expression Tree that takes postfix input from the user and recursively builds and evaluates the expression. Proper input can be assumed.
...
4
votes
2
answers
2k
views
Given a pivot x, and a list lst, partition the list into three parts
The task:
Given a pivot x, and a list lst, partition the list into three parts.
The first part contains all elements in lst that are less than x.
The second part contains all elements in lst that are ...
3
votes
2
answers
110
views
group computed properties in vue component
I have the following vue component which all works fine
...
6
votes
2
answers
444
views
Sending Email Through App Script
Background
This is a function that is part of a library written in GAS. A function inside a library I've written is supposed to send out an email to another user or users with accompanying details (...
17
votes
9
answers
12k
views
Function to test if exactly one of three parameters is truthy, without using equality operators
Given the following instructions I have created a function that achieves the requirements. I feel my function is a bit too complex, though it does what it's supposed to. The difficult part for myself ...
9
votes
2
answers
340
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 ...
2
votes
1
answer
85
views
Session-based authentication using Express.js
I'm currently learning Express.js and I wrote this authentication code. I'm unsure if what i have is correct, how to improve it and if it's secure. For user and session data storage I'm using ...
28
votes
5
answers
66k
views
Drawing a grid on canvas
I have created canvas (800x400) - and filled it with a grid. It works but the rendering of the grid (lines) takes around 3 seconds, which seems excessively long. Am I doing something wrong?
...
0
votes
1
answer
144
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 ...