Skip to main content

All Questions

Tagged with or
Filter by
Sorted by
Tagged with
0 votes
1 answer
212 views

Listener for property value changes in a Javascript object

The purpose of this code is add proxy on nested object for log changes on property. This is a debug utility! ...
2 votes
1 answer
151 views

Simple JS Password System

I created a simple password system using HTML, CSS, and JS to quiz myself on my variable, localstorage, and if and else ...
3 votes
2 answers
99 views

Solving round number in JS by using String

Whatever language you choose, you may encounter a rounding problem. In fact, this is due to the limit of the required number of bits needed to get the right number after a calculation. Simple example: ...
0 votes
1 answer
270 views

Smart and Inututive Auto-Format Date Input

I'm developing a custom date input format to enhance user experience in scenarios where birthdays and expiration dates are inputted. Traditional date fields and date picker libraries often fall short ...
4 votes
0 answers
152 views

Find the longest "common sequence" in two lists

In short, the algorithm must find the longest sequence that joins together common sequences from two lists (a more formal specification is given in the code's header). The lists are assumed to contain ...
4 votes
2 answers
127 views

The core of the assembler (the part of the assembler that actually converts mnemonics to opcodes) is hard to follow due to many if-branchings

For my Bachelor thesis, I made a PicoBlaze Assembler and Emulator in JavaScript. I've discussed it on many Internet forums, and quite a few people have complained that the core of my assembler is hard-...
5 votes
1 answer
314 views

Find the starting indices of all occurrences of the pattern in the string - KMP algorithm follow-up

The task was initially solved here, but was too buggy: Given a string and a pattern, find the starting indices of all occurrences of the pattern in the string. For example, given the string "...
0 votes
1 answer
79 views

Handling pure in browser HTTP request in Service Worker fetch event

I was suggested by @Bergi on StackOverflow that Async Promise constructors are any pattern. The argument behind this is that async Promise swallows the errors. In my case, I have try..catch so I'm not ...
2 votes
2 answers
72 views

French Republican Calendar Converter (Romme Rule)

This is a French Republican Calendar / Gregorian Calendar converter I've written; it returns an accurate date for all the dates I've tested (mostly dates in the present age, although it also lines up ...
1 vote
1 answer
77 views

Javascript CLI to boot iOS simulators, install project, extract data, and merge into JSON

I'm a DIY "dev" - so I really create things that I need or think they'll end up helping others. I wrote this Swift Package so the iOS community could get device bezel radius' to help with UI ...
4 votes
2 answers
445 views

Detecting when a user stops typing

I wanted to detect when a user stops typing. I encountered this answer from SO (Not the selected answer, but the second one which seem to be better): https://stackoverflow.com/a/5926782/17746636 But I ...
5 votes
1 answer
137 views

Partial Function Application in JavaScript

I'm trying to make a partial function from any function. Here is a working example: ...
2 votes
2 answers
493 views

Merge sort implementation using divide-and-conquer

I was told in an interview to write a program for implementing merge sort on the concept of divide-and-conquer. ...
12 votes
2 answers
596 views

Vue - It's the Royal Game of Ur

Background After learning Kotlin for Advent of Code in December, I started looking into cross-compiling Kotlin for both the JVM and to JavaScript. Then I wrote a game server in Kotlin and also a ...
2 votes
1 answer
133 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 ...
4 votes
1 answer
157 views

Convert durations to a single unit

In the codebase I inherited, I have this function which converts a number and unit into milliseconds: ...
5 votes
1 answer
226 views

v-for loop generating list items that will get rearranged based on an associated value (ranking system)

A counter gets incremented by a custom value. Each increment value gets stored with its refcount that tracks how many times it occurred. An ordered list shows all increment values entered so far by ...
5 votes
1 answer
4k views

Drawing a color wheel... faster?

Using the following code, I am able to neatly draw a color wheel, however, performance is barely acceptable on a high end machine. Now, I know some tricks I could employ to make it run far more ...
2 votes
2 answers
73 views

Calculating the sum of all k-sized sub-arrays in an array using sliding window algorithm

I need to calculate the sum of all k-sized sub-arrays in an array using sliding window algorithm. Is that a valid sliding window algorithm? If not, why? ...
2 votes
1 answer
106 views

An extended JavaScript plugin for rendering radial pie charts

(This post is the continuation of A JavaScript plugin for rendering radial pie charts.) (See the continuation of this post.) Now, you can mark up the radial pie charts via XML: ...
1 vote
1 answer
66 views

Observer design pattern: value observer and variable observer implementation

Observer implementation that leverages both behaviours observing a variable and observing for a value. Supports subscribing and withdrawing observers. ...
2 votes
1 answer
74 views

Reorganice (and style) form's output in HTML using JQuery: how to do it better?

To clarify: The code in "What I achieved" is working. I'm looking for suggestions so I can improve. I'm quite new with JQuery (and javascript) and I've been learning while styling a forum. ...
2 votes
1 answer
185 views

Sticky Table Header in Plain JS

I wrote a code for sticky/fixed table header. I am bit confused with my coding, though it does my job. I know there are many jQuery codes available online. But I wanted to do it in plain JS with IE ...
1 vote
2 answers
145 views

Receiving a daily reward

I'm doing a daily reward system on my site. Users can pick up the reward only once a day. The next reward can be picked up the next day, also, only once. When a user visits the site to pick up a daily ...
4 votes
2 answers
1k views

Object key diff

I've been tasked with finding property differences in massive JSON structures and returning them in a particular fashion (i.e. [key_1.key_2, key_1, etc.]). Here's ...
2 votes
2 answers
224 views

Permissions system in MERN app

I am working on a MERN stack app that is a CRM with a couple of modules. Now when the user sends x request to the server to do a supposed action (such as delete something), the server first checks if ...
5 votes
2 answers
233 views

A curry function

I am new to the functional style, and I wrote a curry function to practice this new style. This curry function takes a regular function and returns the curried version of it. Currying is a technique, ...
2 votes
0 answers
103 views

Lcation of redux "random" state initialization

I'm creating 2048 to practice React/Redux. I've got a game board that appropriately shifts, and follows the game rules (it works). I'm more concerned with my understanding of handling Redux reducers (...
3 votes
1 answer
362 views

I need help optimizing a function that returns all divisors

This is my code: export function all_divisors(num: number): number[] { return range(1, num+1).filter(i => num % i === 0).toArray(); } the ...
0 votes
2 answers
286 views

Largest prime factor function

I have written a function which finds the largest prime factor of some number. This function works but the problem is that it is too slow. For instance, when I enter 600851475143 as a parameter, the ...
4 votes
2 answers
15k views

Find the greatest common divisor of n numbers

Just had this as a practice test problem and I'm curious how to optimize for performance. Thanks! The greatest common divisor (GCD), also called the highest common factor (HCF) of N numbers is the ...
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 ? ...
0 votes
1 answer
130 views

A faster way to compute largest prime factor (Again, but a lot better)

I came up with this code after implementing the feedback given by @200_success. The previous one (A faster way to compute the largest prime factor) tested my patience, but still failed to give the ...
2 votes
1 answer
255 views

Hackerrank problem -"Another Prime Problem"

I came across this issue in the problem titled: Another Prime Problem. Here's my solution with JavaScript which passed test case-1, but for other test cases it led to timeout. ...
3 votes
4 answers
194 views

Is this an efficient/correct way to get largest Prime factor?

Is this an efficient way to get the largest prime factor of a given number? Other solutions I found involved nested algorithms. ...
1 vote
0 answers
65 views

Euler Project Problem #3 Optimization Needed

Well I was solving Problem 3 from Project Euler, but I just found out that my code is really bad, it would take so much time to finish processing the code and I honestly do not know how to optimize it....
4 votes
2 answers
190 views

Abundant number implementation

I have implementted a simple JavaScript function to find the list of abundant numbers and print them on the screen. an abundant number is a number for which the sum of its proper divisors is greater ...
0 votes
0 answers
319 views

"Sum by factors" algorithm improvement

I was working on a code challenge with the following description: Given an array of positive or negative integers I= [i1,..,in] you have to produce a sorted array ...
2 votes
1 answer
56 views

Exponentiate common factors with JavaScript

I've created a function that exponentiates common factors. I'd like to optimize/simplify it because, as you can see, it's very messy and not very performant ...
2 votes
4 answers
13k views

Find all factors of an integer

My script finds all factors of an integer. First it finds all prime integers using trial division then it uses the prime factors to find all other factors of the integer. I would like to know how I ...
0 votes
1 answer
44 views

js template engine

I am building a template engine for js and I need some help refactoring the code for fast and more efficient performance. If you can help modify or suggest some updates I'll be grateful. ...
2 votes
0 answers
82 views

Javascript basic search engine recipes

I have made a search engine for recipes. Requirements for this JS Project are as follow: Create a function called searchRecipes that takes all recipes and an ...
4 votes
1 answer
52 views

JavaScript search algorithm to find a town in a particular state

I built a function in JavaScript which executes a search algorithm to find a town in a particular state. The dataset, referenced by the variable townsAndStates is ...
0 votes
1 answer
218 views

Random number generator

Util functions to generate random numbers with upper bound or with both upper and lower bounds: ...
2 votes
0 answers
120 views

Create a Penrose tiling

I programmed this type of Penrose Tilings in javascript and the algorithm is 'simple': The cyan pentagon always have to draw the yellow losenge and the grey pentagon almost always have to draw two red ...
5 votes
3 answers
886 views

Idomatic way to ignore `finally` block after cancelling network request [closed]

In React, it is quite common for me to have something similar to the following. ...
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 ...
1 vote
1 answer
57 views

Click temporization on user interface elements

Implementation to accommodate different behaviours based on the frequency a user interface element is clicked. It supports number of clicks and number of clicks in a time frame. ...
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 ...
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): ...

1
3 4
5
6 7
188