Questions tagged [javascript]

ECMAScript or ES (commonly referred to as JavaScript) is primarily used for scripting web-pages but also has several embedded forms as stand-alone interpreters or JIT compilers. Use this tag for questions regarding all versions of ES up to the current ES8 and its dialects / implementations: JavaScript, JScript, etc., excluding ActionScript.

Filter by
Sorted by
Tagged with
2
votes
0answers
14 views

Google Play billing + Firebase functions: Creating a one-time product, server-side

My Android app must request my Cloud Functions server to create in-app products at runtime ; then, the server responds with the created one-time product. I've written the server Cloud Function that ...
-4
votes
0answers
16 views

variables in FullCalendar [on hold]

hello i'm using fullcalendar and i want to declare event.date as a variable to use it like this: ...
2
votes
0answers
28 views

Simple react app to fetch and display data

This is my first react app and it was for a job interview challenge. The app is really simple and it works, but although I don't think I'm gonna get it, could I have some feedback about what is wrong ...
1
vote
0answers
28 views

Toggling the background color of a page using JavaScript closures

This question is to see if I can get some input on the "design pattern" I tried to implement here. I'm just learning about closure in JavaScript and I think I'm starting to get it. I'm wondering if ...
1
vote
0answers
10 views

Example Multiple Async Await Calls Javascript

I need to make an unknown number of api calls, up to 5 max probably. But most samples I've seen show only a couple of async calls so are effectively hard coded to the number of calls being made. This ...
7
votes
2answers
67 views

Function invocation every second time

Recently I got test task at the project, it is fairly simple: ...
-1
votes
0answers
26 views

Exact same code but there's an error? [on hold]

I've been following this video:https://www.youtube.com/watch?v=YXZX_6RfHjk For some reason my code for the javascript portion is this: ...
5
votes
0answers
23 views

Vanilla Javascript: Chained AJAX request

I'd be grateful for a review of my AJAX request. If I have taken the correct approach here and especially any security concerns! I am creating a Purchase Order system for my manager (as part of an ...
0
votes
0answers
23 views

delete forms which are displayed as images [on hold]

I have a code where I create over a form, images which are supposed to be other forms which can be edited. That's the code how I create them: ...
3
votes
1answer
36 views

Ajax function with a callback

I have Ajax function with a callback which fetches all the Patient data however I have some perfomance issues and trying to figure out what it might be, does anyone have idea? That's my Code ...
2
votes
0answers
26 views

Pure (almost) CSS Masonry

I developed this CSS Masonry. It works with a CSS grid with grid-auto-rows: 1px. There is a JS ...
3
votes
1answer
41 views

JavaScript function to categorize data by their “styles” attribute, and store the key-“unicode” pair

I have a JavaScript function to categorize data by their "styles" attribute, and store the key-"unicode" pair. Here's my current code: ...
0
votes
0answers
17 views

filter a select tag by an input able to find middle characters [on hold]

i have a select with dynamic options and values, and an input so user can type inside the input and select values get limited to those that has typed characters. i found this: similar question link ...
-1
votes
2answers
29 views

Please help refactor these jQuery code selectors for checked and unchecked checkboxes [on hold]

As you can see below, the following code has redundancies: ...
1
vote
1answer
35 views

Dynamically inserting html from external file and updating the database

I need some suggestions on how to approach this. I want to allow users to create sections of website. The code so far is working but since I am new to back-end I feel like there is better, more ...
3
votes
1answer
43 views

Pivotting SQL Table Response to JSON in JavaScript

Issue Our API returns two formats JSON and this SQL table format. I'm not sure what it is truly called so I'll give a few examples below. Like all API responses, it can be a list or a single response ...
-5
votes
0answers
35 views

Find the most occuring string in array with their required level [closed]

input = ['A','A','B','C','C','A','A','D','D','D','D','D','E','A','A'] requiredElements = 3 output = ['A','D','C']. it is possible to change the required elements ...
7
votes
1answer
77 views

Quicksort in JavaScript assuming an immutable array

Update: further succinct versions below (inspired by Haskell) Quick sort in JS assuming an immutable array: ...
2
votes
2answers
52 views

Filter list items

I have a list of items I pull from SharePoint and want to filter them in my custom list view page. So my function works exactly how I want, but it seems messy and I'm hoping someone could point me to ...
2
votes
1answer
25 views

Grid layout component for VueJS

I'm working on a vue.js / nuxt.js project, applying the Atomic Design methodology, I need to do one to set the grid layout and using CSS Grid Layout. I already did the component, but I think I did ...
1
vote
1answer
30 views

Showing a unique result based on options selected

I created a simple quiz in HTML/CSS and plain Javascript. There are three questions with two options each, so there are eight possible combinations of answers, and therefore results. You can only pick ...
2
votes
1answer
21 views

Throttle implementation using pure JavaScript adding and removing event listener

I am trying to implement throttle function in vanilla JavaScript. I have seen other implementations on the web, but the way I have implemented it is more understandable for myself. I was wondering if ...
-4
votes
1answer
380 views

The HEADING should have 2 SPAN elements [closed]

1: Create a DIV and give it a data-cart-info attribute. Inside the DIV, create a HEADING with mdc-typography--headline4" as its CSS class 2: The HEADING should have 2 SPAN elements. The First ...
2
votes
1answer
52 views

Loading in two CSV files and storing them in two separate arrays

As the title says, I'm loading (or at least trying to) two CSV files and store them in two separate arrays. What I have so far worked, but it isn't the most elegant, no efficient solution. The end ...
1
vote
0answers
18 views

Custom hook to handles async calls with loading and error state?

I have built this hook to handle async calls. It should manage state for the loading and ...
2
votes
2answers
41 views

Counting Valleys - HackerRank Challenge

For this challenge on HackerRank: A valley is a sequence of consecutive steps below sea level, starting with a step down from sea level and ending with a step up to sea level. Given Gary's ...
1
vote
0answers
13 views

Node Express App - Create structure around incoming payload [closed]

I am working on a simple NodeJS express app that accepts an incoming payload from a few different systems. There is a single route that ships the data off to another method and waits for the promise. ...
5
votes
1answer
43 views

Build multiple groups in an array

I have written a function buildGroupRequests() to build an array of multiple groups. It checks the size of the request group. If a request group is greater than <...
0
votes
1answer
33 views

Clean up nodeJS function

I'm currently writing an activity reporting system based on users; upon looking through a lot of files I'm noticing that I do a lot of if statements that clearly ...
5
votes
3answers
198 views

Simple Number to Words using a Single Loop String Triplets in JavaScript

I have extensively reviewed 2 old articles on the subject: https://stackoverflow.com/questions/14766951/convert-digits-into-words-with-javascript and https://stackoverflow.com/questions/5529934/...
2
votes
0answers
31 views

localStorage should expire after 24 hours

The following code is checking if the user's browser is IE and if this is the case and there's no localStorage yet, it sets a localStorage, which should be valid for only 24 hours. ...
2
votes
0answers
33 views

jQuery validation for multi-page registration form

I use JS/JQuery validation for radioboxes, input field etc. Because of AJAX I use one global validation (in a separate file) and 4-5 other files to coverage actions in a relevant registration form ...
3
votes
1answer
38 views

Find a Sum of Particles in A Set of Boxes Given a Number of Rows and Columns

This is a code challenge, from Codewars, the details of the specific challenge in depth can be found here: https://www.codewars.com/kata/magnet-particules-in-boxes/javascript. The summary of it ...
8
votes
5answers
2k views

Find The One Element In An Array That is Different From The Others

https://www.codewars.com/kata/find-the-stray-number/train/javascript I solved this challenge by sorting from least to greatest, and checking if the first element in the array matched the second ...
2
votes
1answer
39 views

ReactJS Calling an API and rendering results

I am currently learning JS Frameworks, right now exploring React and wanted to make sure I keep everything in order, as in: the logic of working with React, code quality, any shortcomings, good/bad ...
1
vote
0answers
101 views

Initializing a Node JS Express Application with OOP [closed]

Overview I am attempting to learn Node JS with Express by creating a project. I have seen many examples of setting up an express.js application with functional based programming, like so: ...
2
votes
1answer
66 views

Find A Series of Numbers Who when Squared and Summed are equal to a given Square

I am working on a CodeWars titled 'Square into Squares. Protect trees!' it can be found here: https://www.codewars.com/kata/54eb33e5bc1a25440d000891/train/javascript I have a working solution, the ...
1
vote
1answer
36 views

Using BigInt in JavaScript, write a factorial function that takes either a Number or BigInt and returns a BigInt

Is there anything missing or any pitfall when using BigInt? ...
0
votes
0answers
98 views

Minimum sum of elements, taken 2 at a time

Update: I had not recalled the question correctly and ended up with the wrong question. I have now updated the question and the solution: The question is: Given an array of integers say [8,4,6,12,10] ...
4
votes
0answers
34 views

Border Radius Preview Tool

I am running through an app idea to help improve my knowledge of Javascript. The code attached performs the following: Performs a regex on the input field to check it is value 0-9 If not, it clears ...
1
vote
0answers
17 views

Repetitive light-box gallery code

I'm in the process of making a website for a friend of mine who wants to display both the tattoos he has made, as well as his paintings. The idea for the layout is to have a gallery for his tattoos, ...
2
votes
1answer
45 views

Nodejs functions to load and save RSA keys

I'm creating my first real life Nodejs project. I've created some files and all work, but I'm not satisfied about what my files look likes. It's unreadeble. For example, I work of a file to manage ...
2
votes
0answers
38 views

Wait for an element to exist in DOM before clicking it

Here is the problem: some script is injecting some HTML5 elements (actually a button with the #thebutton ID) to the current DOM. But this is a third party script ...
1
vote
0answers
15 views

Cleaning up get/set functions in Node export

So currently I'm working on cleaning up a recently developed project and notice a lot of potentially un-needed code; whereas I create separate functions for very minimal stuff.. Here's an example of ...
2
votes
1answer
36 views

Basic input system for a few form fields

I am attempting to port a linear function that I designed in a spreadsheet into HTML and Javascript. It's based on linear least squares where I have to take a Matrix and multiply it by its ...
2
votes
0answers
12 views

jQuery - Etch-A-Sketch implementation [closed]

How could I make my code follow the DRY principle? I feel like they are better ways to do things in my code. So any feedback will help me! js fiddle: https://jsfiddle.net/fr6ut238/ ...
2
votes
2answers
67 views

Create User Class

Create a user class with id, name, age. Write a function to get users older than age 20. Group all users with same age and increment users age by 3 Is there a cleaner way to write this? Any comments ...
0
votes
0answers
16 views

Updating a object properties based on another nested object

I have two nested objects where one object decides to remove or keep the other object properties. So based on the userAccessData object I am doing this operation on ...
1
vote
1answer
21 views

Import function vs turning it into custom hook

I have this ProductSearchContainer.js file that it's getting too long to handle and maintain. What it's responsible for: Doing network requests to get a list of ...
0
votes
0answers
15 views

removing the properties based on another object - better way

Based on userAccessData Object i need to filter the properties so what ever properties inside the fields are there they will be exist in the updatedValue, i am able to do it. also one more thing if ...