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

multiple api calls through promise

update1: - I need to make two different api calls. - from the result of first api call I am getting id in the variable firstAPIid, https://reqres.in/api/users?page=2 - I need to pass this id ...
2
votes
1answer
24 views

Reading image files asynchronously and displaying them on the page

I am trying to display images from a folder in my project using the "fs" module with NodeJS. I need to read all images in a directory and run them in a loop for them to be displayed. I was able to do ...
2
votes
1answer
48 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 ...
3
votes
1answer
60 views

Separating items into ordered and unordered lists

I'm trying to group all the types which have ordered-list-item & unordered-list-item into new object. How can I simplify the function and reduce multiple return statements? ...
77
votes
6answers
7k views

You hate h̶a̶t̶s̶ reputation? Click here to get rid of it

Soo... I recently read a meta-post about the inherent problems of reputation. It listed some things like: Confirmation bias. Demotivating for low-rep users. Hubris and elitism of high-rep users over ...
1
vote
0answers
22 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 ...
3
votes
1answer
79 views

React.js Nested Nav Bar

This was written for a coding challenge for a company I recently starting working for. I'm looking for any suggestions on how to clean up the code, as well as any issues anyone thinks may occur as it ...
2
votes
0answers
17 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 ...
3
votes
1answer
39 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 ...
1
vote
5answers
3k views

Project Euler #1 - JavaScript

I'm new to JavaScript, and decided to learn the language by running through as many of the Project Euler problems as I have time to do. I just finished the first one, and am looking for some feedback, ...
7
votes
2answers
73 views

Function invocation every second time

Recently I got test task at the project, it is fairly simple: ...
-4
votes
0answers
17 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: ...
6
votes
6answers
5k views

Best practice and alternatives for string manipulation with an emphasis on readability [on hold]

As a personal habit I generally prefer to use string replace and format methods, along with string "patterns", in lieu of string ...
0
votes
0answers
34 views

Weight-tracking app

A couple of weeks ago I started a little project, I was learning Node/Express/Mongo and I though it was a good idea to start building some app so at least I could refresh my basic React knowledge. ...
2
votes
1answer
190 views

window.innerWidth - workaround for when it returns the wrong value

Some JavaScript libraries relies on window innerWidth and innerHeight to do their calculations ...
2
votes
2answers
58 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
0answers
39 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 ...
6
votes
1answer
75 views

Given a string containing just parentheses, determine if the input string is valid

The task is taken from leetcode Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: ...
2
votes
0answers
28 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 ...
2
votes
0answers
621 views

Deepest pit of an array

Following is based on a problem description from a Codility test, as a task in an interview. DeepestPit - problem description A non-empty zero-indexed array B ...
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: ...
2
votes
1answer
43 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
votes
0answers
27 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
24 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 ...
3
votes
1answer
38 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 ...
4
votes
1answer
70 views

<select multiple> with dropdown

I wanted to use <select multiple> but was annoyed by the poor design on desktops which is why I created a version with dropdown: ...
3
votes
1answer
45 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: ...
7
votes
1answer
82 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
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 ...
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: ...
3
votes
5answers
7k views

Printing staircase revisited

What can be more elegant ways to solve the given problem. # ## ### #### Code: ...
6
votes
1answer
708 views

Datepickers for departure and return dates

I have to two datepickers. I want achieve the following functionality: the return date cannot be selected before the selected departure date and the departure date cannot be after the selected return ...
3
votes
4answers
3k views

Function to find the shortest word in an array, where not every element is a string

I wrote a solution for a codeCamp exercise: Write a function called findShortestWordAmongMixedElements. Given an array, ...
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 ...
1
vote
1answer
37 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 ...
9
votes
2answers
86 views

Fetching movie data using jQuery

Requirements Display movie datas inside all tags that have the class movie_list Make an ajax call for fetching movie datas Fill loading text before fetch data If any error occurs during loading, the ...
2
votes
0answers
72 views

Angular 1 CSS Encapsulation

I am trying to get a good clean way to do CSS Encapsulation in Angular JS. The main goal of this is to use isolated components. This is what I have come up with so far. The method I am using is ...
3
votes
1answer
44 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 ...
6
votes
1answer
183 views

Atomic elements selector engine

I've written a DOM element selector engine that I'm really quite happy with, and I'd love to hear some opinions on it from my fellow JavaScripters :D It's called Atomic, and I've got a repository for ...
3
votes
1answer
416 views

Calling a Luhn check function when a credit card field changes

I feel like I should not be duplicating the code to gather the credit card number, but I am not sure how best to do it. Any suggestions? ...
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 ...
5
votes
3answers
215 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
1answer
53 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 ...
5
votes
3answers
494 views

Find smallest index that is identical to the value in an array

The task is taken from LeetCode Given an array A of distinct integers sorted in ascending order, return the smallest index i that satisfies A[i] == i. Return -1 if no such i exists. ...
5
votes
1answer
44 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 <...
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
42 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. ...