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
3
votes
2answers
434 views

Singly Linked List Implementation in ES6

This is my Singly Linked List implementation in ES6. ...
6
votes
2answers
146 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
41 views

Promise for request/response with timeout

Below is a piece of code that uses a promise for sending a request to a server, and to wait for an answer. Under normal conditions the server will always respond immediately, But of course you don't ...
2
votes
4answers
3k views

A simple function that removes empty or tags containing just ' '

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 ...
3
votes
1answer
113 views

Display and search through a JSON's items in Vue.js

I have put together this small application that displays a "Users" JSON in an HTML5 table. I use Bootstrap 3, Axios and Vue.js 2 for this purpose. Here is the code: ...
4
votes
1answer
119 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 ...
3
votes
2answers
58 views

Storing statistics as JSON in a simulation game

I am working on a choice-based simulation and players have to choose between different locations, I am pushing those choices to an array locationLog and my ...
3
votes
2answers
272 views

Lazy-loading iframes as they scroll into view

I'm working in a Tableau driven system, with large numbers of charts, I needed a way to reduce the strain of the initial load of our app. It's fairly simple, but wanted to ensure I accounted for every ...
0
votes
1answer
64 views

Tile and grid abstraction

This question is a small subset of the problem I am trying to solve. I am trying to learn to break problems into better abstractions. The original problem I am trying to solve is: Write a JS ...
0
votes
1answer
139 views

Custom indexOf for strings javascript with regex

I was wondering how efficient my code is creating custom indexOf for strings in JavaScript using regex instead of looping with a for statement the whole way in most ...
8
votes
2answers
511 views

Two player snake game

I created a 2 player Snake game from my original one player version. I am looking for some feedback on how I made it. I think I could use improvement when handling input (...
3
votes
2answers
82 views

Data formatting, splitting objects & deleting key's/values

I am quite bad at data manipulation and after a lot of time I was finally able to get it working how I wanted. The thing is I don't like all the delete operations, I think the code can be a lot ...
3
votes
3answers
113 views

Showing statistics of popular JavaScript frameworks from GitHub API

I am currently working on a simple app to check the stats of popular javascript frameworks. For this I am using the Github API to get certain data sets and have come close to finishing my project. <...
4
votes
3answers
73 views

Take a limited number of items from a potentially infinite generator

Hypothetically, I have a bunch of generators that never end, like: function* progression() { let n = 0; while (true) { yield n++; } } I want to take ...
4
votes
1answer
167 views

Node.JS Server Queue Processor

I implemented a simple queuing system for my Node.JS app and wanted a critique on it's structure. ...
1
vote
4answers
256 views

Function to determine the direction of an arrow

I have a function in a project that I feel could be written better. The purpose of the function is to return the direction of an arrow based on two parameters. ...
1
vote
0answers
27 views

Selecting rows on condition in a table

I have a table with courses. The user that is currently logged in can mark these courses as attended and unattended. There can be multiple rows selected. The logic for this row selecting looks ...
4
votes
1answer
107 views

JavaScript canvas Snake game

This is my 3rd JavaScript canvas game. It's basically just snake right now but I am planning on adding some more aspects to it soon. I was wondering if I could get some feedback especially on how I'm ...
0
votes
1answer
109 views

Return the first word with the greatest number of repeated letters

I'm learning JavaScript and have written a function that accepts a string and returns the first word with the greatest number of repeated letters. For example: Input:"Hello apple pie" - Output:"Hello"...
2
votes
3answers
95 views

Extracting data in ES6

I have this array const idArray = ["12", "231", "73", "4"] and an object ...
1
vote
1answer
46 views

Turn a list of words into a dictionary

I am looking for a way to turn a list of words that may have duplicates into a dictionary/map that counts the number of occurrences of words. After spending some time with the problem, this seems to ...
0
votes
1answer
38 views

Is this a good way to use Try catch? [closed]

I'm new to handling errors and am not sure how to do it, basically, in a speicific request err.code === 11000 is not actually an error, but expected behaviour. I ...
6
votes
3answers
591 views

Compute count of unique words using ES6 sets

I have written a function which counts how many unique words are included in a given text. The source-code: ...
5
votes
2answers
4k views

Reformatting a date from YYYY-MM-DD to MM/DD/YYYY

In this small bit of JavaScript, a date is passed in as YYYY-MM-DD. It's formatted like this to be passed to the backend system. On the front end, we need to ...
2
votes
2answers
89 views

Simple form validation in javascript

Used to use Laravel's easy to use form validation class, decided to mimic it in JS. I've been learning JS for 4 days now and decided to write my first piece of real code. I'm pretty sure its full of ...
2
votes
1answer
103 views

Manipulating arrays to extract unique objects and count occurrences

The data describes cycling activities (key1) and chunks of them (key2). In total there are around 1,000 ...
3
votes
1answer
65 views

Vue component over-complication

I'm building a date range selector, and while this works, I feel like I'm making it more complicated than it needs to be. Is there a more elegant way of writing this? Possibly using computed values ...
1
vote
1answer
28 views

Test-Spy Implementation

I have tried to write a test-spy myself. Just for getting more familar with the topic. Here's the code: ...
0
votes
1answer
41 views

Mapping properties between two Objects of different structure

Something I've found myself having to do reasonably often is map properties from an Object (usually a heavily nested MongoDB document) to a different 'shape' to then pass it to a function call or API ...
1
vote
1answer
2k views

Dispatching Vuex getter via setInterval

I am fetching the friend list for a chat application using a Vuex store. I need to dispatch the getter via an interval. Is there a best practices way to do this? ...
1
vote
0answers
64 views

JavaScript time series data combination

I've written code that performs a merge of two streams of sorted time series data. The first stream is taken to be the primary and any successive streams are merged into it, using the nearest ...
2
votes
1answer
77 views

O(n) Object Pool

I recently rewrote my object pool design to \$O(n)\$ complexity. I did this using a linked list, which is not native in JavaScript. It does not, unfortunately, automatically assign ...
1
vote
1answer
38 views

duplicated operator(or attribute) on the same input control - v-model and @change

I wrote a code like below - It is nuxt.js, which is one of the Vue frameworks. This code will be expected to When change event triggered, update ...
1
vote
2answers
113 views

Find if cookie name exists in the cookie string

I need to determine whether a cookie name is available or not in the cookie string. I have achieved this. We can use cookie-parser package but I don't want to use that package so I have written the ...
6
votes
1answer
206 views

Jest unit test that handles a wrapped Promise

I've wrapped an imported function (a promise) and attempted to write unit tests that bring my codebase to 100% coverage. ...
2
votes
1answer
114 views

create static page with vuejs

I have a static homepage with some routes and thought about creating this with VueJs. I am totally new to this and just know NodeJs with Handlebars. So normally I would have something like this <...
2
votes
1answer
39 views

Request for improvements on a simple React app

I'm looking for a review of a recent project I finished for school. It is an app that functions like Twitter. It includes an Express server and Routes. Instead of using databases, it uses JSON files. ...
2
votes
2answers
253 views

JS calculator, respecting order of operations

I have a function that receives an array of numbers and operations Ex: userEntry = [3,+,3,x,3] -> returns 12 It is a calculator that adheres to the proper ...
2
votes
1answer
1k views

TamperMonkey script to add a button to Jira

The below script detects whether we are in Jira, and if it is run in Jira it will add a button. Clicking that button will use the REST API of Jira to create an issue, and navigate to the recently ...
2
votes
1answer
1k views

Editable table admin panel using Vuejs & Datatables

I'm trying to learn Vuejs and started this project: https://github.com/GhitaB/datatables-admin (Live demo: https://ghitab.github.io/datatables-admin/). Copied the current version (the question will ...
3
votes
1answer
907 views

D3 Updating stacked bar chart

In my data there can be different number of bars in each chart. Here is a picture: When pressing the button labeled change bars layout the view of the charts toggles between horizontal and vertical ...
2
votes
2answers
161 views

Validate Email as User is typing (JavaScript)

I have the following javascript function validateEmail(value). The goal of the function is to validate the users inputted email as they are typing. So if someone puts nfg@*gmail.com the email will be ...
0
votes
1answer
35 views

Best Approach for Assignment Code in Node.js (ES6 style) [closed]

Is there any way to improve this code? Using ES6 style i am using latest stable version of node.js. ...
4
votes
2answers
496 views

Small Javascript elevator simulation

I created a small Javascript elevator simulation that works as expected, however, being pretty new to Javascript I can t help but feel like this code in unnecessarily complex. Honestly any feedback ...
1
vote
2answers
92 views

Font and color checker chrome extension in JavaScript

I have written this code for a color and font checker on a webpage. The code is current and not so good. I would really like if I can get comments, reviews or any better approach for my PoC. PoC: I ...
5
votes
5answers
662 views

Average of two hex colour values

I have submitted the following bit of script as the answer to one of the tasks I was set by a recruiter. My submission has already been made and cannot be altered. However, I am keen to ask how you ...
4
votes
1answer
115 views

Audio frequency trainer / tester using Web Audio API

I'm making an audio frequency trainer as a learning exercise. It could be useful for audio technicians who need to recognize audio frequencies (eg. when ringing out feedback during a live concert or ...
-1
votes
1answer
69 views

Combine Matrix Columns JavaScript

I did this Codepen to combine all the columns from one matrix in JS. ...
1
vote
1answer
46 views

Traversing the Parent-child relationship between objects: Part 2

This code builds on the code in the previous iteration. All of the following tests should work: ...
2
votes
1answer
138 views

Simple Duration calculator using es6 class syntax

I've written a simple script that calculates the distance between two points in time and returns the duration. Example: Start - 11:00, End - 11:45, Duration - 0.75 I wanted to make use of ES6 ...

1 2 3
4
5
11