Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
12 views

Optimizing Datatables table of tens of thousands of client-provided rows

We have this employees table, that looks like this: that contains 16,530 employee rows. As expected, this table takes more than 30 seconds to load. I have been tasked with speeding it up somehow. ...
1
vote
0answers
50 views

ReactJS Typewriting animation

One of the dream idea to build typewriting in ReactJS. The code seems to be working, still there are something looks not that great in the code 😔 Looking for better solution (best practice) in the ...
1
vote
1answer
65 views

Using a public API to display data

It's a simple app that uses a public API to display data. It works as is, but I'm seeing a lot of spaghetti code that my limited experience can't fix on its own. ...
1
vote
1answer
37 views

Efficiently aggregating nested data

Problem Given the following data: ...
-1
votes
1answer
45 views

Evaluating expressions in “case” vs using “if/else if” [closed]

I was just tempted to write a similar piece of code to the one presented in this answer on SO (posted below). The problem is having to discriminate between different cases where exactly one case is ...
1
vote
1answer
51 views

Queue implementation in ES6 [closed]

Here's my Queue implementation in ES6, ...
0
votes
0answers
40 views

HackerRank - Left Rotation in JavaScript

I'm looking to learn more about data structures, time complexity, and efficient algorithms. I have solved the Left Rotation Problem on HackerRank using JavaScript. I am looking to see ways to optimize ...
1
vote
1answer
17 views

Summary page with react-redux: container or presentational component

I'm building a Summary page for merchant activity in a marketplace with react and redux. The application has already a structure where there is a "MerchantContianer" ...
0
votes
0answers
30 views

A better way to retrieve data in firebase using redux

So i want to be able to make the following method inside of componentWillMount more robust, and essentially put this method inside an actions function. Post.js <...
0
votes
1answer
50 views

Experimenting with a OOP design pattern in JavaScript

Initially, I was using the class syntax to structure my code. While it sure did feel nice to work with, I found it lacked some important functionalities, like ...
3
votes
2answers
117 views

Singly Linked List Implementation in ES6

This is my Singly Linked List implementation in ES6. ...
1
vote
0answers
45 views

Sorting options within a select element

I am trying to sort the options within a SELECT element. I wonder if I am doing it stupidly or not, so perhaps someone can look ...
3
votes
1answer
54 views

Leetcode Mountain Array

I've been working on longest mountain in array on Leetcode: Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold: ...
1
vote
1answer
144 views

jQuery Slideshow with pagination

The code below is for a slideshow that shows a slide with class active, pre-loads a slide with class next, and holds the slide with class last in the background. My biggest issue with this is there ...
1
vote
3answers
53 views

Change state depending on holidays, weekends or hour of day

I'm writing a script that's changing the background color depending on hour of day, if it is a weekend or if it is a Swedish holiday. I have a functional script and as I want to improve my programming ...
1
vote
0answers
30 views

Rendering custom components with React Route parameters [closed]

I am not able to render custom components via the Route and 'return' attribute on Route. I'm not getting any errors with my code, so it must be something that I am missing. But basically what I am ...
5
votes
2answers
88 views

Find top two clothing sizes in the array

I was recently asked this question in an interview. Here is the solution I came up with. Please let know if I could have done this differently or in a more efficient manner. The question is as ...
1
vote
1answer
55 views

Zig-zag child element with Flexbox and JavaScript

Recently I found a question on StackOverflow that seemed very interesting: How to make HTML elements "zig zag" this way: ...
2
votes
0answers
17 views

Bookmarklet to quickly fill an input with a maximum width string for visual testing purposes

I'm currently working on a complete overhaul of the CSS of our flagship product with a goal of maintainability and simplification. During the testing, my coworkers and I have found that a lot of pages ...
1
vote
1answer
43 views

Monitoring navigation function: logic judgment

Write a simple monitoring navigation function. I feel logic judgment still needs to be optimized. I don't have a clear idea right now about code logic such as reducing ...
2
votes
1answer
35 views

Wrapping fetch(), preserve promise-based API for outer function

One of my react component's methods is using an async fetch() internally. After fetching the response from the server, it is being converted to JSON, then I perform a check on that JSON string. ...
0
votes
2answers
63 views

Get property value from object tree in a recursive way

Consider the following structure, let condition = { and: [ { id: 3 }, { pageId: '1' } ] } I want to get the id property value ...
2
votes
1answer
44 views

Await socket Response

I wrote this to make the "callback hell" more manageable on the part of the coder when using Socket IO, so that there wasn't really any callback hell to go with, just a simple await. This should work ...
18
votes
7answers
8k views

FizzBuzz in Javascript

I'm sure everyone here knows what FizzBuzz is. I would like constructive criticism for my solution. I'm a beginner to programming as a whole and this isn't my first solution, but it's what I think is ...
1
vote
0answers
72 views

My first vanilla Javascript shopping cart

I made a vanilla Javascript shopping cart using sessionStorage. This way users can navigate pages without losing data. The checkout form sends to paypal. A self invoking function initializes event ...
2
votes
0answers
29 views

Grouped stacked bar chart in d3js

I've the following d3 chart which is both grouped and each grouped contains a stacked bar. But somehow, I feel this is not a proper way to implement and little complicated. If there was only stacked ...
1
vote
4answers
58 views

Replacement function for jQuery .post

Today I just completed a personal POST function that emulates jQuery's using $.ajax, but also implementing a possible redirect. I just finished up and it looks like it is functional, but since this is ...
1
vote
1answer
31 views

A simple jQuery function that removes empty or tags containing just '&nbsp;'

I've made a simple function, this time in jQuery rather than JS, that just removes empty <p></p>, span and strong tags. I'm curious to see what everyone ...
0
votes
1answer
39 views

NodeJS commit message validator

I wrote a commit message validator + CLI in NodeJS. Notes: My greatest concern is that the patten I use to represent the results of a validation is inadequate. Options: Use adhoc enums Create a <...
2
votes
1answer
135 views

Execute promise tree in order of declaration

I have created a little framework for my work to manage loading and unloading plugins by using a modular tree structure that is based on Promises. I would like to be able to create the tree structure,...
1
vote
0answers
35 views

Learning Javascript - Is this a messy implementation of a Javascript Slider?

I've been learning JS for a few months now and I've just finished creating a small image slider for a website. The sliders functionality is as follows: Continuously cycle through images and loop back ...
3
votes
1answer
36 views

Min Heap Implementation

Min Heap Implementation As an exercise, I wanted to implement a min heap using JavaScript. I'm not terribly familiar with JavaScript best practices, so I wanted to get feedback on my approach. ...
3
votes
1answer
138 views

Find longest common string subsequence

The task (also found at https://www.youtube.com/watch?v=10WnvBk9sZc): Write a function that takes two strings, s1 and s2, and returns the longest common subsequence of s1 and s2. "ABAZDC", "...
1
vote
1answer
57 views

Unsplash jQuery plugin with callback functionality

This is my first attempt at a jQuery plugin and really doing anything with jQuery which isn't simple DOM manipulation or initialising another plugin! I'm really keen to learn where I have gone wrong ...
2
votes
4answers
79 views

A simple function that removes empty or tags containing just '&nbsp;'

I've written a function that should get rid of empty p, span, etc tags and those with just ' ' and am looking for ways to improve it. My original solution was very 'wet', but I've managed to come ...
-2
votes
1answer
46 views

Updating text with JavaScript and Firebase [closed]

My problem is this causes more lag as time goes on. I use this commonly to chat with my friends, and I need it the site to update in real-time whenever a message gets edited/deleted/added. Any ...
1
vote
2answers
123 views

Simple menu with descriptions

If one menu-item is clicked then the description with the same data-filter attribute should be shown. I added a class to the description elements to associate each one with the affiliated menu item. ...
1
vote
2answers
69 views

Simple ES6 Truncate method for character, word, and sentence limits

Simple truncating method for characters, words, and sentences for a personal utility library I've been working on. Improvements & criticism welcomed! Especially around default param usage, as I'...
2
votes
2answers
60 views

Displaying information extracted from an HTML table

This function below (used on a timeout due to my page loading time) displays information on my site. I grab this data from my table view that I load into the page. It is launched by clicking a button ...
5
votes
3answers
139 views

LeetCode 189 - Rotate Array

I have a working solution for this problem that was accepted in LeetCode: Given an array, rotate the array to the right by k steps, where k is non-negative." ...
0
votes
1answer
28 views

Pure JS countdown clock not converting millisecond time correctly [closed]

I have a semisimple pure js countdown clock that I am having trouble converting the millisecond time correctly. Here is a working Plunker (besides the date counter) It Should only be 38 days instead ...
0
votes
1answer
30 views

Place a button after an input and show it's password in plain text

I have managed to achieve this action through this: ...
1
vote
2answers
73 views

jQuery code to detect whether form fields have the default value when a checkbox is unchecked

How could I rewrite this jquery code to compact it in a more elegant form: ...
2
votes
4answers
121 views
1
vote
2answers
53 views

Form a string consisting of the common letters that appear in two input strings

The idea is to write a function that takes two strings and returns a new string that repeats in the previous two: examples: ...
1
vote
0answers
28 views

MySQL database connector

I want to connect to a MySQL database in JavaScript in an OOP compliant fashion. I'm not sure if I'm trying to adapt my Js code to read like Java too much. I'm wanting to learn how to store 'vars' ...
1
vote
0answers
25 views

change a string and apply changes to other similar strings

I'm trying to get the changes that were made in a string and apply them to similar strings. string are similar if they are equal from 0 to index of change. let's say I have this strings: ...
1
vote
1answer
50 views

A 'slow sort': repeatedly swap the first misordered pair

A 'slow sort' is probably the slowest practical sort. It compares each element with the elements after it, and swaps immediately if one is greater than the other, and goes back to the start of the ...
2
votes
1answer
83 views

React Component Design

Building out a React component that is supposed to hold the following information and display it in a feed-like page. The idea is to later map over the individual entries in an array. Author ...
-1
votes
2answers
56 views

Takes a value from website; places it into an object [closed]

I'm almost sure that this can be done more efficiently than it is, but I've spent about 30 minutes just staring at my screen. This is for a home project, but I'm using it as a way to improve my coding,...