Questions tagged [ecmascript-6]

ECMAScript 6 reached feature complete status in 2014. The features vary widely from completely new objects and patterns to syntax changes to new methods on existing objects.

Filter by
Sorted by
Tagged with
1
vote
1answer
28 views

Cyclomatic Complexity (complexity)

I have a program for finding shortest distance/path and I got a correct answer but I am getting an issue i.e., "Function 'shortestPath' has a complexity of 9. Maximum allowed is 6." This is ...
7
votes
2answers
78 views

Error solution: Uncaught TypeError

Uncaught TypeError: document.getElementById(...) is null I have a single JavaScript file that is connected to multiple pages. The below snippet is a function that is used for a single page. The above ...
7
votes
2answers
214 views

Animated Calendar using HTML + CSS + JS

I'm a beginner developer and I'm building a calendar for smartphones. I'm using HTML, CSS and JS. I'm not entirely done with the project yet, however, I have the feeling that I'm making a messy code. ...
11
votes
3answers
922 views

Split string algorithm

I just wanted to get ideas on how to improve my algorithm, the requirements are as follows: You are given a string S consisting of letters 'a' and 'b'. You want to split it into three separate non-...
7
votes
3answers
181 views

parse date and number from API results

I'm slurping up fields from an API that returns an array of fields. Each field in the array is a String that actually contains two separate fields (a number and a date). The number is enclosed in ...
2
votes
1answer
40 views

Infinite Slider Conversion to Prototype

I've found the following example of an infinite slider to use on a project but as I will have multiple instances I have converted it to a prototype. The original example https://medium.com/@...
9
votes
6answers
1k views

Method to delegate command to other methods

Since I am working alone on this, I would like someone who would take a look and point out any mistakes or things I could have done better. My questions: How could I improve this big switch statement?...
5
votes
3answers
95 views

Removing unneeded objects from an array before rendering

I'm making a function that adds a new object to an array and removes the oldest if it has reached a specific length. Click the button in the example below. All objects are drawn until its array ...
2
votes
1answer
26 views

Multiple audio player - arrow keys & space

I am creating a VueJS component of an audio player. I am having some difficulties in finding the ideal way to get the arrow keys and space to work. I have found a solution, however I think it is not ...
5
votes
1answer
93 views

Game of Life state calculation in javascript

I've created a Life implementation in javascript with the goal to be as fast as possible, with the rendering I'm satisfied (see picture bellow), hovever the next state calculation is really slow and I'...
6
votes
3answers
1k views

Counting words from stored .md files

The following searches recursively for all the .md files inside a folder. It then stores the text of the files in an array. Finally, it sums their word count using ...
4
votes
2answers
98 views

Regular expression to get a string between two strings where the last string can also be 'end of string'

I intend to extract a URL search parameter value using a regular expression in plain javascript. The parameter can be in any order in the search query. So is there a better approach than 👇? ...
6
votes
4answers
1k views

Convert minutes portion of time to decimal

I am making an hours calculator app. It takes a start time, end time and time taken for lunch. For the start and end time it takes a four-digit hh:mm time. For example, 10:20. I have made a function ...
0
votes
1answer
50 views

Refactor multiple if condition in JavaScript/TypeScript

I want to refactor this code but am wondering how I should start it. I'm not sure this code is totally against clean code or not. I'm thinking to use RxJS or a JavaScript builtin method. I'd like to ...
4
votes
2answers
94 views

JavaScript Priority Queue implementation using a binary heap

I'm currently going over Robert Sedgewick's Algorithms book. For the implementation of A priority queue using a binary heap I implemented the code using ES6. I believe to have more experience with ...
3
votes
2answers
48 views

Node JS and Handlebars checking if records have been completed today

Goal: Currently creating an application using Node JS and Handlebars. I have a to do list set up in ...
1
vote
2answers
60 views

Javascript to-do application for native Javascript

I did a simple to-do application for native Javascript. This is my first time, previously I used only jQuery. What recommendations would be useful? https://codepen.io/denibudeyko/pen/MWyEmox ...
0
votes
1answer
43 views

Efficiently performing multiple nested grouping and mapping in Javascript

I have an array of log objects with log_types and dates, like this: ...
2
votes
2answers
108 views

Structuring code logic for events on laravel controller

The code below will store a base64 image on another website and create an event to display the image on a Vue page in real time. It works fine and all. My question is, is this a good way of doing it ...
9
votes
2answers
264 views

Manifest.JS: A lightweight front-end structural framework

Code review scope My goal with this review is to receive big-picture observations and suggestions for improving the efficiency / ease of writing the front end of a web application with this basic ...
7
votes
2answers
239 views

Serving a webpage that displays the HTTP request information sent by the client

In order to learn web server programming in Node and JavaScript, I decided to implement a simple web server that only does one thing: Display data of the HTTP request as an HTML table. The actual ...
4
votes
1answer
91 views

Check whether '.' and '/' are escaped properly

I'm currently using a function to check if a URL has correctly escaped two different characters: . and /. To escape a character ...
6
votes
1answer
67 views

Team scrambler VueJs

I wanted to do a very little project of a team scrambler. There are two teams of 5 players. Each player has a unique color (in his team) from a limited pool. You can use 2 actions : Scramble the ...
9
votes
2answers
219 views

Huffman encoding

The Huffman-Algorithm The Huffman-Algorithm, named after David A. Huffman who first published this algorithm in 1952, is a algorithm for lossless data compression. As most encoding-methods, the words ...
2
votes
0answers
57 views

Which one should I choose for simple task: async/await or promise.then?

I made a helper function for drawing the map(OpenLayers). Then I made another helper function for fetch(axios.get) the map URL. ...
4
votes
1answer
115 views

Pattern usage for increment / decrement React (Hooks)

When asked to increment / decrement a particular value I usually create specific functions to handle this functionality. Like this: ...
3
votes
1answer
109 views

GroupBy by nodeJS or ES6 of very nested JSON Objects with condition

The following code should return an array (flatFeatures) which will include feature.name and the most far subscription.expDate. for example if I have some subscriptions with the same features, the ...
7
votes
3answers
118 views

Stopwatch interface OOP (Vanilla JS)

I'm learning OOP and the first exercise of the course was to made a Stopwatch class. I did it really fast and decided to make an interface for this little app. I created the interface. Basically I ...
2
votes
1answer
46 views

Client side authorization when retrieving from server

I have an endpoint to retrieve the user's authorization based on Joseph Silber's Bouncer. I have a global can() function. It creates a unique key based on the ...
4
votes
1answer
119 views

Extract string list as array from an array of objects

Having the following array of objects of ingredients used by cooks ...
3
votes
1answer
79 views

JS + CANVAS Projectile Motion

Basically you've got a canvas, and you can click it to launch a ball in a certain angle and speed, everything is working fine, except for the arrow tip of the vector thing. I can't get it to draw ...
7
votes
3answers
351 views

Javascript split array into n subarrays, size of chunks don't matter

NOTE: This post was moved from stackoverflow as codereview.stackexchange is a better place to discuss the performance of this code problem/solution. I want to split ...
3
votes
2answers
96 views

Quicksort implementation in JavaScript

I implemented Quicksort in JavaScript. I'm trying to follow the best principles in JavaScript. In Ruby when you declare classes your able to use private for the ...
4
votes
1answer
124 views

Sorting an object by value w/ `sort` and `reduce`

Given an object with unsorted numeric values, such as: const unsorted = { green: 80, blue: 90, red: 30, yellow: 100, } We want a data structure with the ...
2
votes
1answer
35 views

Iterating an Array Object & Assigning the Attributes Values to those that Match the Condition

Is there any approaches to reduce the below coding snippet in Angular 2+ with few lines of code by making use of ECMA Script or by some other ways ...
5
votes
1answer
136 views

Working with images in multiple formats

I've been doing some research around how to best make use of the WebP images (with fallback) in React. Most solutions point to something similar to what I've written below. That means if I have a lot ...
2
votes
2answers
49 views

How can I simplify this JQuery validation process?

How can I simplify this functioning JQuery validation process: ...
6
votes
2answers
81 views

JS Custom Event System

I've written the following custom event system module and I'm planning to use it in production in the future. Before I do that, I'd like to ask for general suggestions on how to improve it. Thanks a ...
11
votes
5answers
1k views

Vue.js search functionality

In my BlogList.vue component I made a search input field: ...
3
votes
4answers
119 views

Digital Clock Script

While learning JavaScript I thought it was a good idea to make a digital clock program. I followed a youtube tutorial (with some tweaks to my preference) and came up with my final code that I have. I ...
2
votes
3answers
91 views

Handling arrow keys and tabIndex

I'm wondering how to "beautify"/"simplify" this code: ...
12
votes
3answers
320 views

MMMRjs a product of BYTES Genesis

We have published a product today called MMMR.js this product is licensed under the MIT license and is built by Syed Mohammad Sannan. The uniqueness of this product is that it is built with and for ...
2
votes
2answers
58 views

String data manipulated given CSV variables

The Requirements: List the expensable items sorted by date and location given two variables: 'categories' and 'expenses'. The Categories variable provides the following information in order: Category ...
1
vote
1answer
21 views

Javascript: Mapping combinations of input and possible suffix arrays leads to repetitive if statements

I am writing a program to combine the basic form of a word with suffix arrays following the choices from a form group (Angular 9) to receive the declination. This is the flow: The user inputs a word....
4
votes
1answer
122 views

Leetcode three sum in Javascript

I was doing 3sum question on leetcode Question Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum ...
5
votes
2answers
94 views

Delays using multiple for loops

I got this script which work perfectly but I got some delays because of this 2 for loops [i][j] is there any way to do the same ...
3
votes
2answers
87 views

Huffman Encoding in Javascript

So, I've implemented Huffman Encoding in JavaScript, you can see it live here. Here is the code: ...
0
votes
1answer
98 views

Best way to preload images with callback on completion with pure JavaScript (ES6)

There are many related questions and answers but mostly with JQuery and/or from many years ago. I prepared a version myself, and my question is whether this is currently (2020, hence ECMAScript 6 or ...
2
votes
1answer
126 views

Array of random values that changes over time

I had a project with repetitive HTML, JS code blocks in which should be ten fields (A, B, C...) with certain functionality. Three fields are already implemented, but I don't want to copy and paste ...

1
2 3 4 5
12