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
3
votes
0answers
64 views

converting from byte arrays to strings of integers, and back

I have this code to go from an array of bytes (arbitrarily long) to a "bigint" string (really, an arbitrarily long string composed of integers 0-9), and go from that long integer string into ...
0
votes
0answers
26 views

Refactor Javascript filter that handles click and changing together dropdown filters

I'm looking to rework and make it easier to read this handleFilterChange function This is helper being used in the function ...
1
vote
2answers
56 views

A function to find all the primes between two numbers whose reverse is also a prime and doesn't include palindrome, in JS

I am trying to solve a challenge in which I have to write a function that takes in two numbers as arguments and returns an array containing numbers between them which are prime and their reverse is ...
1
vote
1answer
74 views

Detecting supported browsers in ASP.NET MVC (Server side vs. Client side)

I want to check client's browser version, and if it's too old, display a message that the user should update their browser in order to use the website. The website is built using ASP.NET MVC. I have ...
2
votes
1answer
42 views

table pagination

What I'm trying to do is quite simple: my table has pagination. So if I have 12 items to show and my max items per page is 10, I will have 2 pages, one with 10 records and another with just 2. I ...
1
vote
1answer
47 views

Best way to make a scroll top/bottom button

So I've made a button in the right-bottom corner of my HTML-page, but I was wondering since it's the first time I've made this, if there is another better way to do this, or if you guys can see ...
0
votes
1answer
34 views

HTML table with repeatable rows and live-calculated column totals with row grouping indication

I created a quick "demonstration of proposal behavior" tool for my post on MSO: A proposal to put ALL answerers on a path to curating better content. Because I have never asked for a review ...
-2
votes
1answer
35 views

undefined instead of innerHTML [closed]

element.parentNode.parentNode.children[3].innerHTML is fine but not ...
4
votes
0answers
55 views

Find and replace text in a webpage with JavaScript

I am new to web development and would like to get feedback on a JavaScript library that automatically finds and replaces text on a webpage using the MutationObserver interface. EDIT: Seeing that this ...
1
vote
0answers
30 views

How to implement robust and secure session management (in general, and in Next.js)

I am using Next.js and want to properly implement session management into this serverless architecture. I checked out nextauth but I am not really a fan and it doesn't implement some things I think I ...
2
votes
1answer
68 views

Randomly place Divs on webpage and make sure they don't overlap

Currently I am working on a project for which I want to have the different links (div elements) placed randomly on my webpage. To accomplish this, I first generate a set of coordinates and later check ...
0
votes
3answers
52 views

Javascript: Reducing redundancy of notation nested value

Hello I have this function that looks for nested value 3 levels deep currently ...
0
votes
0answers
18 views

Trying to secure a payment transaction with mysqljs2

In my web app, I am trying to secure a payment transaction, that is: prevent users spending more than they have, especially in the case of concurrent execution and prevent partial execution. ...
2
votes
1answer
42 views

A renderer; JavaScript game beginnings

I recently started making a game in JavaScript, but I've only really built the renderer. This is the first 'real' game I started working on and I don't know if I'm doing any major things wrong and if ...
6
votes
2answers
63 views

Basic AVG length of a decimal number program

It's my first time using stack exchange and getting my code reviewed, so if you find any issues with this post, please tell me. Anyway, I have done a very simple program in JS to find the average ...
0
votes
1answer
43 views

React debounce using Lodash

I need people who have experience with React to review my code. I want to make a debounce using Lodash. import debounce from 'lodash/debounce' ...
0
votes
2answers
60 views

Portfolio Website Responsive Design

I'm a new developer just starting out learning HTML5, CSS3 and JavaScript. Below is my attempt at building a portfolio website. I am finding it difficult getting my site to respond better when ...
2
votes
2answers
167 views

Using JavaScript, given a JSON value, recursively find all JSON objects, then sort keys in-place

Some background: JavaScript is not my primary language, so I'm looking to get some constructive criticism here. I built a tiny single page HTML app that pretty prints JSON text. It's very useful when ...
2
votes
1answer
26 views

Recording keypress and clicking the link that corresponds to the pressed characters

I'm recording which keys are being pressed. After pressing two keys, the first link that matches the two characters will be highlighted. After pressing one more key, the link that corresponds to those ...
3
votes
1answer
48 views

Javascript Word Vectors Demo

This is my WIP attempt at an open-source web demo for exploring word vectors as part of my research. The functionality will be explained separately from the site. It is also my first time using HTML, ...
7
votes
1answer
94 views

Cursed error generator in Javascript

I've made some code that generates cursed error messages like this, for my new language Javastack: ...
-2
votes
1answer
53 views

How to prevent repetitive returns for almost same contitions in IF and ELSE?

I have a for which loops for X files, if the current file is the file Y i have to skip it if the condition ...
2
votes
1answer
40 views

Spicetify extension to generate a playlist of songs with similar audio features

I decided to make an extension for Spicetify (modified Spotify client). It generates a playlist of similar songs based on their average audio features. ...
2
votes
1answer
31 views

developer portfolio website

I'm a new developer just starting out learning HTML, css and JavaScript. Below is my attempt at building a portfolio website. I am finding it difficult positioning elements the way I want to and ...
0
votes
1answer
56 views

Shortest Path to Get All Keys in JavaScript

I build the Shortest Path to Get All Keys algorithm in JavaScript. It's working properly, but with a really bad performance. The problem: You are given an m x n grid grid where: '.' is an empty cell. '...
3
votes
1answer
72 views

garbage string remover with array or object input

This is the second time I am writing any practical JavaScript so it is pretty likely that I have messed something up. I am beginner, so just need a piece of advice before sharing the code: Do I need ...
4
votes
2answers
1k views

Stack Implementation in JavaScript

I am learning data structures and below is my implementation of a stack in JavaScript. I didn't want to use built in functions for an array because in JavaScript that would be too easy, so I made my ...
2
votes
1answer
56 views

Project Euler 1 using functional programming in JS

So I am once again beating a dead horse, by solving the first Project Euler problem: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these ...
2
votes
1answer
44 views

Generate Multiple Instances of Canvas-based UI Object

Background I'm interested in implementing a small script to display multiple independent instances of a Canvas-based control on one page. The ultimate intention is to add many similar controls to the ...
1
vote
1answer
59 views

Hidden html elements after search click

I want to: Hide areas of my template after search click. Return its original state with the cleaning of the input related to each button. I don't know if my code exploits all the resources of ...
-1
votes
1answer
46 views

JS - Same recurring statements in if-else

I have this watcher in my app.vue that makes sure the right theme attribute is set on the ...
-1
votes
1answer
73 views

Simplifying and optimising function logic [closed]

I asked the same question on StackOverflow but was told to instead ask here since it was better suited. I have a function that I implemented. It is doing a lot of heavy lifting. I would like to ...
2
votes
2answers
66 views

First non-repeating character in string

I've been trying to learn a bit of JavaScript over the last few weeks, and inspired by this current hot network question, I tried creating a function for finding the first non-repeating character in a ...
1
vote
1answer
79 views

Which of these two Vuetify Navigation Drawer prevent prop mutation workarounds seem better?

I am very new to Vue.js, I just stumbled on a very hard thing to do (at least for me) where Vue was complaining about mutating a prop (children shouldn't change parent props apparently). I was about ...
2
votes
2answers
71 views

JS script fetching GitHub API for personal website

I've built a very simple personal website, everything is in a single file because it is very straightforward, but I think the JS script could be better structured. All it does is fetch some repos from ...
1
vote
1answer
86 views

list of games to open radar match in iframe on for drop-down controls

In general my page is slow and has several points in the code that I believe can be improved, even in relation to the structure used. Anyway, the biggest problem is: The page I'm creating is very ...
2
votes
1answer
54 views

Is this a reasonable way to test/compare javascript loop speeds?

I'm playing around with understanding array looping speed. I'm trying to make the contenders equivalent and close to realistic. Is this a good approach? Are there other iteration approaches to test? ...
1
vote
1answer
71 views

Maximum Profit in Job Scheduling - Performance Issue

I implemented the Maximum Profit in Job Scheduling algorithm in JavaScript, but I'm having performance issue. The problem: We have n jobs, where every job is scheduled to be done from startTime[i] to ...
-1
votes
1answer
33 views

refactor multi if statements and checking for div existence in a better style

I want to refactor this code to a better version without all this repetition, this code is working 100% the way it is right now but every refactoring effort is making it useless, any idea or can this ...
3
votes
2answers
128 views

Single user Electron application allowing basic CRUD operation on a table (stored in JSON)

I am completely new to JavaScript and I will be grateful for your comments on my Electron app (electron is a JS framework allowing to create of desktop apps). I needed to create an application that ...
1
vote
1answer
94 views

Square Spiral Matrix in Javascript

I've been grinding some Leetcode for an interview coming up and just completed Square Spiral in Javascript. Looking for feedback on performance. This ranked faster than 58% of submissions, would there ...
2
votes
1answer
108 views

In how many different ways can a group of 9 people be divided into 3 groups, with each group containing 3 people?

To divide 9 persons into 3 groups, when the ordering of groups is not important can be done in (9C3 * 6C3 * 3C3) / (3!) = 280 ways Here, we divide by (3!) because the ordering of 3 groups is not ...
3
votes
2answers
87 views

Javascript (ES11) Event System implementation

So I decided to implement a basic event system in JavaScript. My goal was to support the following functions: on - allows the user to register a handler on the ...
0
votes
1answer
25 views

Appending script from within function to header [closed]

I'm attempting to import an external script into an HTML file. The name of the js file that I want to import is hosted in a SQL database. Therefore, I am using a XMLHttpRequest to access the SQL ...
1
vote
0answers
49 views

Genetic Algorithm Typescript

I learnt a little about genetic algorithm. And I made a program from typescript that tries to evolve and match word/sentence using genetic algorithm. But if I give a little longer sentence it takes ...
1
vote
1answer
57 views

Recursively access deeply nested object

Problem Statement I need to access a deeply nested object. I could've used a 3rd party util such as Lodash but insisted myself on writing a Vanilla JS solution with a recursive strategy. Code Can this ...
1
vote
1answer
29 views

abstract navigationOptions react navigation

I have many stacks with the same navigation options, how do I abstract the navigationOptions part to have it repeat in all my stacks? ...
1
vote
0answers
27 views

Mix JavaScript debounce (not plugin) with jQuery event handler?

I asked this on StackOverflow and was directed here... Instead of including a debounce plugin library for a very small form section of my site, I've implemented some of David Walsh's JavaScript ...
0
votes
1answer
43 views

Refractor a function call [closed]

I am working on an API call in pure Javascript and I hit a section of code that i want to refractor The code is something like this ...