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
8
votes
2answers
160 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
80 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
110 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
71 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
144 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
234 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. ...
0
votes
0answers
20 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 like ...
4
votes
1answer
91 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
49 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
91 views

Extracting data in ES6

I have this array const idArray = ["12", "231", "73", "4"] and an object ...
1
vote
1answer
43 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
492 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: ...
4
votes
2answers
1k 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
78 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
100 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
54 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
26 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
36 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
772 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
44 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
60 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
30 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
103 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
80 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
82 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
38 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
113 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
650 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
599 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 ...
1
vote
1answer
630 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
140 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
34 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. ...
3
votes
2answers
214 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
89 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
395 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
109 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
67 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
94 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 ...
5
votes
1answer
149 views

Animating a screw made up of elements

I am working on code to generate a screw made up of different elements and animating it by rotatation. The elements are so called conveying elements (denoted by GFA)...
8
votes
3answers
529 views

Draw sine wave going around a circle

I have used d3 to draw a sine wave going around a circle. This is the very first time I've used d3 or drawn a SVG and I'm fairly new to JS as well, so I don't know if I've overcomplicated it/if there ...
2
votes
1answer
65 views

Javascript / ES6 parse value from arrays of objects

I want to write a generic parser which takes a value, and type and returns label of given value instead. Currently, this is my code: ...
6
votes
2answers
319 views

Cake-ordering form and calculator

I’m a designer learning to code and I’ve built a simple form calculator for ordering cakes. I would love it if you could show me how to make the code more idiomatic. How can it be more consistent, ...
4
votes
2answers
268 views

Arkanoid/Breakout clone with ThreeJS

Here's my attempt at an Arkanoid/Breakout clone using JavaScript with ThreeJS. The feedback I'm looking for is more on the code side; the game itself is a work in progress. You can take it for a spin ...
2
votes
2answers
52 views

Dim Hero & Add Background to Nav on scroll

I have followed a tutorial that initially was for adding a 'sticky' nav. I adapted this slightly so it adds a background to the Nav when the page scroll reaches the top-third point of the hero area. ...
0
votes
2answers
72 views

JavaScript Armstrong Number Validator (ES6)

I have the following function which takes in an input and validates if that input is an Armstrong number or not: An Armstrong Number is a number such that the sum of the cubes of its digits is ...
5
votes
2answers
98 views

Event emitter npm module

I was asked to complete the task described below: Event Emitters are objects that serve as the core building block in event-driven architectures. They simplify the process of handling asynchronous ...
1
vote
1answer
56 views

Building query params which append to URL in a browser

I was looking for a similar JavaScript method for http_build_query but did not find but create my own and here I am a bit confused to decide the right approach. ...
5
votes
2answers
117 views

Upvote/counter in Javascript

Looking to improve building UI in pure ES6. This is the pattern I have adopted and has worked fairly well. This code increments the count, sets a data attribute to toggle the button, and issues a ...