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
4
votes
1answer
59 views

Generate all partitions of a set of items

Here are the items: var item = ['a', 'b', 'c', 'd']; Desired output: ...
0
votes
1answer
51 views

Import XML files to MongoDb with Nodejs

Here is my code which will read XML files and import the data to MongoDb. Do you have any comments on my code? ...
1
vote
5answers
126 views

FizzBuzz solution

I'm preparing for junior developer interviews and am trying to come up with a more interesting/versatile solution to FizzBuzz than I've done in the past. Do you have any ideas of how I might DRY this ...
0
votes
2answers
40 views

Looping Array object with conditions and comparison the performance with ECMA VS Vanilla JS

The Plain vanilla JS needs to converted in to advanced ECMA. The below 3 snippets shown yields the correct result. Need to identify which among them is performance oriented ...
2
votes
1answer
36 views

Countdown Timer evaluation

Please consider evaluating the code below for best practices, efficiency, and mistakes. I got some of the code from W3 schools (I know, I know, but they've come a long way) and assimilated it to what ...
1
vote
3answers
51 views

function to get input group for user

I got tasked with writing a page that will add as many profile entries as the user wants, and web programming is not at all my field. There are multiple input groups but I'm just using the "age&...
1
vote
1answer
39 views

Avoid the object/array check and treat the return value the same way with JavaScript spread operator?

I'm trying to implement a function (a template-helper function) which provides a simple merge-like functionality for both arrays and objects. The two functions are basically looks identical: ...
1
vote
2answers
65 views

Create a simple hangman game using OOP and Javascript

I had a task to create a simple hangman game using O.O.P. with Javascript. It had to render the puzzle and remaining guesses to the DOM but didn't require any C.S.S. This is what I created. This is my ...
2
votes
1answer
43 views

Filtering Array Based on Element Values

Required to splice specific element value in an array based on the condition. Both the below code does the same job and yields the correct results. But couldn't figure out how to reduce coding ...
0
votes
1answer
59 views

Transform this to one line arrow function ES6+

I am using one line arrow functions a lot, if they are well written I believe they can make code easier to read. I believe that the following code can be easily transformed into one liner but I can't ...
4
votes
2answers
72 views

A better solution for nested maps

I'm trying to build a nav, but the way I currently have the data setup I'm having to map within a map with a map to get all of my data out - I have a feeling that this is a poor way of doing something ...
4
votes
3answers
247 views

Microsoft OA | Longest Substring Without 3 Contiguous Occurrences of Letter

For the following question, does my JS Solution seem correct? I'm looking for some peer review. Q: Given a string s containing only a and b, find longest substring of s such that s does not contain ...
6
votes
2answers
82 views

Type ahead in JS

I've been following Wes Bos challenge, I wrote the code myself then looked at his finished example. Here's my code (I only wrote the JS): ...
8
votes
2answers
224 views

Flex panels in CSS and JS

I was following Wes Bos JS 30-day challenge, so HTML and CSS are mostly are copy-paste, I'd like feedback on JS (mostly). Thanks. ...
2
votes
2answers
76 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 ...
8
votes
3answers
658 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 ...
11
votes
2answers
149 views

A simple parser generator

I need to parse simple DSLs in a few projects. Since I don't know BNF or other grammars, I figured an alternative would be to use a simple parser generator. I'm looking for improvements to the lexer/...
7
votes
2answers
278 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. ...
7
votes
3answers
186 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
76 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/@...
4
votes
2answers
83 views

Very basic Vue todo list viewer

Problem I keep trying to use various todo lists. But I keep coming back to the same situation; not having an active todo list. This can come in two forms: I don't have a habit to open bespoke ...
5
votes
3answers
97 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
37 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 bar to work. I have found a solution, however I think it is ...
6
votes
2answers
131 views

Game of Life state calculation in javascript

I've created a Game of Life implementation in JavaScript with the goal of having it be as fast as possible, with the rendering I'm satisfied (see picture bellow), however the next state calculation is ...
7
votes
3answers
1k views

Counting words from stored .md files

The following searches recursively for all the mark down files - i. ending with the extension .md - inside a folder. It then stores the text of the files in an ...
4
votes
2answers
1k 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
60 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
106 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
51 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
67 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 ...
4
votes
2answers
115 views

Project builder Google Chrome Extension

In the process of learning JavaScript, I built a Google Chrome extension. It works but as I am adding more features the code is quickly getting duplicated, so I'm looking for ways to improve it. This ...
0
votes
1answer
45 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
112 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
276 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
243 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
94 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
69 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
236 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
59 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
444 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
148 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
124 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
51 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
147 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
151 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
611 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
100 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
179 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 ...
3
votes
1answer
45 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 ...

1
2 3 4 5
13