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
1 vote
1 answer
135 views

Rock, paper, scissors game in expressjs typescript

This is a simple 2 player game made in NodeJS and the ExpressJS framework with typescript. I've built using OOP approach to as far of an extent as I know of it. I'm really curious as to how further ...
Exodus Reed's user avatar
2 votes
1 answer
103 views

JavaScript implementation of PHP's array_intersect_key()

I've written a JavaScript function to imitate PHP's array_intersect_key() function for objects. PHP uses arrays as both arrays and objects but JavaScript treats arrays and objects differently. I'm ...
CJ Dennis's user avatar
  • 249
1 vote
1 answer
58 views

Match an array of date strings to the current calendar selection

I have an input array of month-year strings of disabled months selected by the user: ...
pileup's user avatar
  • 451
2 votes
0 answers
26 views

Calculating the worst outcome from a list of values

Given an array of severity from an external risk management system ...
baitendbidz's user avatar
1 vote
1 answer
129 views

Sign Up Page - A mini Frontend Project

I have designed a a small frontend project, a sign-up page. It uses HTML, CSS, JavaScript and jQuery. Being a beginner to frontend development, I want to adapt to all the best practices. I am looking ...
Ultimate's user avatar
  • 143
4 votes
2 answers
89 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 ...
Delfino's user avatar
  • 509
1 vote
1 answer
70 views

PaginationBar component that renders links or buttons depending on optional callback prop

I have several components/pages in my personal project that contain complex logic and even nested ternary operators. Since I'm the only person working on this project, I don't have a hard time ...
Florian Walther's user avatar
1 vote
1 answer
153 views

Copy and Pasting Values from Spreadsheets

Background This code is apart of a library I'm developing for my company. It takes in anywhere from 3 to 5 arguments. All of the code functions properly. To be more specific, a user has data on a ...
Lofton Gentry's user avatar
3 votes
1 answer
972 views

Adding classes from a given array or an object

I want to add classes to elements based on a source array or object. For example, it can be: ...
pileup's user avatar
  • 451
4 votes
2 answers
189 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 ...
Napoleon Bonaparte's user avatar
2 votes
1 answer
56 views

Multiplayer javscript game client side

Any improvement suggestions are welcome, as I'm not the best at making games lol. I have it structured like how Java would be because in the future I want to make it run on java and in the browser. ...
cs6413110's user avatar
1 vote
1 answer
385 views

adding characters on mouseover using Svelte

This is my first time using svelte. I am also using tailwind and astro but that is irrelevant. The following component prepends >> to my text when it is ...
Anm's user avatar
  • 141
6 votes
2 answers
436 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 (...
Lofton Gentry's user avatar
1 vote
1 answer
84 views

Pulling Data from an Email and Pasting it into a Google Spreadsheet

Background The reason why I'm doing this is because at my company, we get emails a lot from different locations that have relevant data we need for other processes. The problem is that this data is ...
Lofton Gentry's user avatar
2 votes
2 answers
911 views

Clone Div and change input control

I am using keypress to get all the events of a input control. Once the user hits the enter button after I am then clone a div and update the ids. One project I am having is that I only want to do this ...
Jefferson's user avatar
  • 353
1 vote
1 answer
132 views

Transform an array into object and set index for an unique key in javascript

I have a method that merges keys and indexes from an array into an object. I'm stuck with ways to compress this method, and I don't know what I can do to make it simpler. Goal get an array of objects ...
wittgenstein's user avatar
2 votes
1 answer
76 views

Helper functions to get, set and remove from Firefox browser storage. Also, to get, push and remove from lists stored in the database

I am making a plugin for Firefox, this is (more or less) my first time working with JavaScript. Is this a reasonable design for working with both values and lists in a database? ...
Emil Holmsten's user avatar
1 vote
0 answers
637 views

Select product variations using buttons/swatches instead of a dropdown

In WooCommerce, by default interface, selecting product variations is possible through a dropdown. But, I am developing a site where I wanted buttons/swatches instead of the dropdown. I achieved that ...
Chotu Kaalia's user avatar
1 vote
0 answers
81 views

Display a list with (opened and closed) folders

I'm working on a script on Foobar that displays a list of playlists with some of these playlists that can be in a folder (that can be opened or closed). For example: As you can see there may be 2 ...
Sebastien Chemouny's user avatar
4 votes
1 answer
3k views

Merge two dictionaries

This function merges two dictionaries, using the value from the later dictionary to resolve conflicts. I have 5 tests that the program passes successfully: ...
alorl's user avatar
  • 41
2 votes
1 answer
244 views

Display WordPress Custom Post Types with ACF-Fields on a Google map

I am currently working on my first WordPress plugin. I display custom post types on a google map with pins. The custom post types also have additional information by ACF fields which are displayed in ...
Markus's user avatar
  • 21
0 votes
2 answers
104 views

Complex statement in typescript get?

I have some get function like this ...
Miomir Dancevic's user avatar
1 vote
1 answer
109 views

Stream Implementation In JavaScript

I usually do not create Streams, but it seems that JavaScript doesn't have a built-in one and I figured I would do it for a personal project I am working on. This code seems to work as intended and ...
Matthew's user avatar
  • 281
0 votes
2 answers
116 views

How to write repetitive styled components in a cleaner way

I'm using Styled Components for styling and there are many icons defined in the project so in the style file we have this code: my-component.styles.ts ...
Leo Messi's user avatar
  • 181
0 votes
2 answers
2k views

JQuery fixed header that hides on scroll down and shows on scroll up

I am currently working on a site product where I have to create a site-header that is always fixed on top of the viewport but when I scroll down it hides, and again when I scroll up, it becomes ...
Chotu Kaalia's user avatar
-1 votes
1 answer
196 views

Test the log in functionality of a web page with incorrect credentials [closed]

I'm new to playwright, so I'm unsure if this is the correct or best way to go about testing. I basically want multiple tests on the same webpage. I've been able to successfully accomplish this using ...
Aeton's user avatar
  • 3
2 votes
2 answers
261 views

React component which uses another component for rendering

Having this React component: ...
Leo Messi's user avatar
  • 181
2 votes
1 answer
171 views

Command handlers in node.js

Description This javascript code uses tmi.js to listen for chat messages in a Twitch chat and perform certain actions depending on their content. In the sample code ...
Patrick Christie's user avatar
2 votes
0 answers
33 views

"Github contribution"-clone made with VueJs. Any logic improvements?

I took a shoot at writing a Github contribution clone using Vuej, tippy.js and tailwindcss. Githubs looks like this: My working clone looks like this: Its not an exact look-a-like but im getting ...
Adam's user avatar
  • 223
-2 votes
1 answer
66 views

Reducing complexity and making it more readable [closed]

I have this NodeJS code which I need to Reduce complexity and making it more readable coz it has to many repeatable loops, and the api is very slow how do i fix this. ...
Prajwal K Rao's user avatar
2 votes
0 answers
42 views

Reactive objects, like in vue

I like the reactivity of vue and created a function that makes Object's reactive. Just like in vue 3 .reactive I wonder if my ...
Marc's user avatar
  • 153
3 votes
1 answer
129 views

How can I condense my code in node.js for sorting unique values within an array?

Kattis problem - ("I've been everywhere") I would highly recommend looking at the problem through the link, however I will summarize it a bit here and explain the functionality of each part ...
doroshm's user avatar
  • 33
0 votes
1 answer
88 views

Ajax to load data for company products without refreshing the page

I am using AJAX script to fetch data from a database. For example, it has Motorola Samsung Apple as company and I use AJAX to fetch models of it, so that when Apple is selected then it shows Apple ...
Ruchika's user avatar
  • 103
1 vote
1 answer
200 views

Terminal War Game

First I would like to thank everyone for whatever help you may offer me. In full disclosure this is a project for a bootcamp class I have. My problem is, and I've asked them about this, that they aren'...
Infinite Grasp's user avatar
0 votes
1 answer
60 views

AJAX script to load data for mobile phones from table

Am using AJAX script to have data fetched from database. For example has Motorola Samsung Apple as company and using AJAX to fetch models of it. Like when apple is selected then it shows apple ...
Ruchika's user avatar
  • 103
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 ...
knot22's user avatar
  • 469
2 votes
2 answers
247 views

How to handle optional date parameters?

When creating a function to be reusable throughout the project I came across something strange. After looking at this function it looks very much like it could be refactored. The function should only ...
ARNON's user avatar
  • 401
0 votes
2 answers
106 views

Is this a watertight javascript sandbox?

I am making a sandbox environment for javascript. For this I create a webworker with this function: (self is a webworkers global context) ...
Nightfall's user avatar
1 vote
1 answer
241 views

Chrome bookmarklet to expand examples elements on a dictionary webpage

I created the following Chrome bookmarklet to open all elements with text Extra Examples boxes on this page. For example - the element labeled with text Extra Examples below can be clicked: When it ...
Mori's user avatar
  • 85
0 votes
2 answers
168 views

simple countdown to halloween project

I just started to learning JavaScript and i did this below code for a simple countdown to halloween project ...
Victor Ferreira Diniz's user avatar
1 vote
2 answers
190 views

Implementation of aho corasick algorithm - slow suffix construction

EDIT: Dequeu was the correct guess EDIT: I did the BFS method for the suffix link/output link construction I'm doing a hackerrank challenge and I came up with this implementation of the aho corasick ...
Nicolas Menettrier's user avatar
0 votes
1 answer
73 views

Convert strConflictedYesReviewers data into a single object which is grouped by ownerid and make array of opportunityid

I get a dynamic string(strConflictedYesReviewers) which contains multiple user recordswhere each record is separated by semicolon and then each record represents ownerid and opportunityid separated by ...
Karim Ali's user avatar
  • 105
3 votes
1 answer
44 views

Generate total property sold for given postcode

I had to implement the below as a coding challenge. There are two http endpoints. The first http endpoints returns a list of postcodes. The second http endpoint takes a postcode as a parameter and ...
hulike2286's user avatar
1 vote
1 answer
54 views

Javascipt non stackable level generator

My task was to create a function that returns the level of a user. A user has a certain amount of XP. Each level is level * 10 xp so for example level 1 would be ...
user267065's user avatar
1 vote
0 answers
128 views

How to simplify Tarjan's algorithm implementation in JavaScript and make it non-recursive (i.e. iterative)?

I adapted this Tarjan algorithm in JavaScript to be a little more functional and not pollute the Vertex object with temporary metadata, and arrived here: ...
HareSurf's user avatar
  • 341
3 votes
2 answers
117 views

Idempotent JavaScript script loader

I wrote an idempotent script loader (for the browser), where the same script won't be loaded more than once. scriptLoader.js: ...
lonix's user avatar
  • 143
3 votes
1 answer
1k views

Insert json object into existing Json array

I have created a tool to insert JSON objects with several rules: Read the product status, and then insert based on the status If there is no data in this status, then insert the object If there is ...
ilham ramadhan's user avatar
2 votes
1 answer
136 views

Finding the 4 squares that sums up to a given number

I wrote this algorithm in JS with the main goal that it will give an answer for 10^750-10^1000 in 2-3 seconds but it solves 10^150 in 2-3 seconds so I am a little far from my goal, the problem is ...
user avatar
5 votes
1 answer
278 views

Function to format time, from seconds to a particular expresion

From an integer X representing a time duration in seconds produce a simplified string representation. For example, given X=100, you should output: "1m40s" Use the following abbreviations w,d,...
Leandro Tabak's user avatar
2 votes
1 answer
164 views

Building HTML in JS and append

I am working on this project where I need to building html from this object. There a a lot of loops and counter and wanted to see if there is a better way to do this Any suggestions/comments are ...
Jefferson's user avatar
  • 353

1
3 4
5
6 7
190