Stack Exchange Network

Stack Exchange network consists of 174 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 [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.

5
votes
5answers
126 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
72 views
+50

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
0answers
21 views

Request a better ECMA6 alternative for this piece of code [closed]

I am trying to write a weighted average scoring with some custom defined formulae. I am a old school java script guy. This is how a ECMA5 code looks like which is giving proper results. please suggest ...
-1
votes
0answers
46 views

Nested array of objects filtering - es6 [closed]

So below is the array of objects and I'm trying to filter only the objects which doesn't have type:x. As you see the array of objects can also contain nested array ...
-1
votes
1answer
56 views

Combine Matrix Columns JavaScript

I did this Codepen to combine all the columns from one matrix in JS. ...
0
votes
0answers
27 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
36 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
140 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
187 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
58 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
229 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
192 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 ...
0
votes
2answers
51 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
56 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
28 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
75 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 ...
2
votes
1answer
56 views

Greasemonkey script to auto fill the values of a form on a specified page

I created a Greasemonkey script to allow me to quickly fill a specific form on a specific URL, for testing/dev purposes. If the current URL matches any of the urls found in the ...
4
votes
3answers
63 views

Breaking group of items into rows then ensure consistent height of each row element

I'm working on a product category page where the product images have inconsistent heights so I've been asked to improve the page appearance without changing the images. The page contains x number of ...
0
votes
1answer
28 views

Destructure array and use object shorthand assignment

I have the following code: ...
3
votes
2answers
42 views

Making the font as big as possible without overflowing each div

I made a function that makes font sizes in <div>s as big as possible without overflowing. It takes a long time to run. How do I optimize this? ...
5
votes
1answer
288 views

Traversing the parent-child relationship between objects

I wrote this code because I was often annoyed that I couldn't get the parent object. This class allows you to traverse the parent-child relationship between objects, in both directions. It also ...
4
votes
1answer
45 views

Filter by multiple options - also only if not empty

Here's how my json looks like. I'm trying to write a function which filters based on participantCriteria.criteriaType & participantCriteria._id ...
0
votes
2answers
115 views

Filter array of objects by comparing nested object properties

I recently had a problem whereby I wanted to filter objects in an array by comparing the values of nested properties of each object to see if there were duplicates. I have tried to explain as ...
4
votes
4answers
92 views

Filtering a name Array in JavaScript

I was wondering if there is a better, more elegant way to write the following JavaScript code block: ...
2
votes
0answers
55 views

JavaScript attempt at an aspect oriented logger using proxies and reflect

I've been playing around with AOP in JavaScript to create a Logger that I can attach to classes and output what is going on (mainly instantiation, calling of functions and the results from functions). ...
1
vote
1answer
97 views

JavaScript Determine if Array has Almost Increasing Sequence

A coding challenge on a website says to determine if an array would have an increasing sequence if one element were removed from that array. Here is the function: ...
3
votes
0answers
38 views

Replicating Chrome console's JavaScript object explorer

This is a follow-up post of my previous question: Displaying JavaScript object's structure on page with HTML which looked at how to display all properties of a JavaScript object on a page similar to ...
3
votes
1answer
64 views

Produces a string based on rules

I was recently playing around with some code, and someone mentioned that my code uses too many classes. I didn't realize I've been doing ES6 incorrectly for so long. I'm having a hard time finding a ...
2
votes
0answers
11 views

Combining immutable lists of strings with each other

The Problem Create a javascript method which combines each string of two immutable lists with each other: ...
6
votes
1answer
73 views

map of SF transit cars

Please provide general and any specific criticism of the following which is intended to provide a map of SF transit cars. The code can be viewed in the working version and also in a group of gists. ...
5
votes
1answer
98 views

Displaying JavaScript object's structure on page with HTML

I wanted to reproduce the type of navigation system found in the console of Firefox and Chrome: you can explore an object's properties by unfolding boxes: So I'm searching to: display all of the ...
3
votes
0answers
69 views

Scraping StackOverflow's questions with Node.js

I'm new to node and web scraping in general but with some research I've written this working code. My goal is to get all questions from X Stack Overflow's pages sorted by most rated and save that ...
6
votes
3answers
177 views

My re-written snake game in Javascript

This a snake game I wrote about 1 month ago. It's working well. Looking for any suggestions for my code, I want my coding improved. jsfiddle link http://jsfiddle.net/geswhvdc/ ...
6
votes
1answer
83 views

Chart of Percentage questions Answered

Every day, Duga reports the number of unanswered questions and percentage of answered questions (after she calls the API endpoint /info) in The 2nd Monitor (so we ...
10
votes
1answer
296 views

Card based computer game

This is a 2 player (Will soon have AI in it - I am not asking for help with AI) game with mechanics similar to the card game named Magic the Gathering. Bear with me, this is a lot of code. If you ...
3
votes
2answers
107 views

Creating and updating link to instagram image or video

I've been using the InstagramPhotoLink extension for Opera for some time but instagram broke it recently. I thought I could try to fix it... and I did. The original extension is rather limited and ...
6
votes
1answer
261 views

JavaScript telegram bot that sends images based on user search

In my freetime, I did this little Telegram bot in Node.js that provides some basic text-based commands and one command where a user can search for an image in order for the bot to send back an image ...
3
votes
2answers
174 views

Creating nested objects from string

I implemented a method, to create an object based on a series of strings that are passed to it, of any depth or length. The way I implemented the solution was to map over the arguments. Assuming that ...
2
votes
0answers
40 views

Simple npm module allowing users to create Sets of objects

I'm a junior developer and I've recently created a simple npm module that was designed to allow users to create Sets of objects in JavaScript. This was done by implementing a single class ...
1
vote
1answer
33 views

Node router for marketplace routes

After cleaning up & some refactoring, one module of my code became like below. However, I'm feeling like there's still some unnecessary redundancy, and it can be improved further and look neater. ...
7
votes
1answer
103 views

Code Challenge: Catching Car Mileage Numbers - 4 kyu Kata from CodeWars

Challenge Story: "7777...8?!??!", exclaimed Bob, "I missed it again! Argh!" Every time there's an interesting number coming up, he notices and then promptly forgets. Who doesn't like catching ...
1
vote
1answer
55 views

Validity checks for a user signup process

Background: I have been working on a service which allows users to signup on different apps and on each login checks if the request is valid or not based on a series of checks. The below snippet is ...
0
votes
0answers
10 views

update object property based on previous value Object.assign

I have one object and its keys value initialized with 0, Now if I want to increase the value of that key from the previous value than how to do it in an efficient manner with the concept of ...
5
votes
2answers
91 views

Simple math game in JavaScript

Created a simple math (addition/subtraction) game to practice my JavaScript. Any feedback on the JavaScript appreciated. Can play in: CodePen Instructions: A math equation will show up and simply ...
5
votes
1answer
57 views

Utilities for Various Builtins #2

This is the final iteration of an iterative review. The previous iteration can be found here: Utilities for various builtins #1 This code solves the following issue: ...
3
votes
4answers
108 views

Find the longest length of sequence of 1-bits achievable by flipping a single bit from 0 to 1 in a number

Problem Statement The problem is defined in the book as following: 5.3 You have an integer and you can flip exactly one bit from 0 to ...
1
vote
1answer
38 views

Utilities for various builtins #1

This is an iterative review. The next iteration is located here: Utilities for Various Builtins #2 This code puts several builtins (And a few non-builtins) into the base classes. ...
3
votes
0answers
62 views

3D 1st Person Snake Game #3

Final iteration of an iterative review. The previous iteration is here: 3D 1st Person Snake Game #2 Here is the snippet: ...
5
votes
1answer
88 views

3D 1st Person Snake Game #2

This is an iterative review of this question: 3D 1st Person Snake Game #1 The next iteration can be found here: 3D 1st Person Snake Game #3 Here is a snippet of the code: ...
6
votes
1answer
94 views

Multiple stacks implemented via a linked lists on top of single fixed-size array

Problem Statement Originally, the problem is defined in the book as following: Describe how you could use a single array to implement three stacks. — Cracking the Coding Interview (6th edition) ...