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
1answer
55 views

Most performant way to check if elements are overlapping [closed]

I know you can calculate if an element is overlapping another by comparing the top|bottom|right|left properties within the getBoundingClientRect method. However, you need to loop through the elements ...
3
votes
1answer
92 views

Implementing `Promise.all()`

I took a stab at implementing Promise.all(): ...
2
votes
1answer
48 views

Rewrite of Array.join

While rewriting Array so I can practice my javascript, I looked at my implementation of .join(). It seems a little clunky to me. ...
4
votes
2answers
73 views

Transform an object into another object structure

I've got such an input object, which I should modify in order to use it with some charts library. ...
8
votes
5answers
764 views

Expanding powers of expressions of the form ax+b

I solved the following problem: Write a function expand that takes in an expression with a single, one character variable, and expands it. The expression is in the form ...
6
votes
5answers
192 views

Get n-th perfect number

The task: A number is considered perfect if its digits sum up to exactly 10. Given a positive integer n, return the n-th perfect number. For example, given 1, you should return 19. Given ...
0
votes
0answers
24 views

Small global state handler in React using hooks

I've been working in React for a while now and I decided to try out my knowledge in hooks by creating a small global state manager using said hooks. This is what I came up with: index.js ...
4
votes
2answers
242 views

Blogging application with Codeigniter back-end and AngularJS front-end

I am working on a blog application with Codeigniter 3.1.8 and AngularJS v1.7.8. The Dashboard of the application is "pure" Codeigniter, with Models, Controllers, and views, while the fronted is made ...
5
votes
2answers
189 views

Frequency Queries (Hackerrank)

This is the problem: You are given queries. Each query is of the form two integers described below: 1 x: Insert x in your data structure. 2 y: Delete one occurrence of y from your data ...
3
votes
2answers
78 views

Encode/decode number pairs to letters

My application state is represented by a string of numbers and I'm trying to encode the string so that it is as small as possible (ie. fewest number of characters). An example string would be: ...
4
votes
1answer
38 views

Efficient way to efficiently merge arrays of objects in JavaScript

I have the below scenario where I am trying to merge two arrays of objects. The current code works, but I am looking for a more efficient way. ...
4
votes
1answer
278 views

Disabling a form button while there's an http request running

I have a form built with react, formik and yup, and this form has some async validations. Apparently, some users were able to bypass these validations, and to prevent some errors, I wanted to disable ...
6
votes
1answer
121 views

Recursive component JSON configuration builder

My goal here is to make data driven nested forms in React. I've created a function that points to a form configuration JSON, which can contain both components and references to other configuration ...
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 ...
4
votes
2answers
181 views

Alternative code to classes in Javascript?

I'm new to JavaScript and came across classes in ES6. Though they are great, I don't want to learn something that can be done in other ways. So, I created this code that does somehow similar job to ...
1
vote
0answers
41 views

ES6 Class for getting GitHub PR info

I was learning some DOM manipulation and interaction with third-party APIs by building a simple interface to get the people who commented on a PR on GitHub. I got great feedback for my initial ...
6
votes
1answer
70 views

Determine if a section is in view

i am currently learning to do things with vanilla Javascript. No plugins, libraries or code snippets. I want to do things on my own, so that I understand 100% of what is happening. I wrote a little ...
2
votes
1answer
69 views

Modern HTTP-Requests for login/register system

I am working on a login/register system and want the register and log in process as smooth as possible. One way of making it smoother is in my opinion to make a multi-step login/register. What I ...
2
votes
1answer
109 views

Loading KML files into leaflet Javascript map

This is working code for input KML files into leaflet map ...
6
votes
0answers
111 views

Node.JS Protobuf socket client with TLS support

I'm working with one environment which allows me to execute node.js code from single file without installing additional modules. My task is to write simple ssl socket client which will send protobuf ...
5
votes
2answers
100 views

Simple replacement for Redux in ES6

The idea about this code is that it's a full replacement of Redux — in 22 lines of code. ...
6
votes
1answer
483 views

Dungeon crawler map using JavaScript

I finally made a "full dungeon crawler map" thanks to this. The map looks great to me and I'd like to hear some useful advice from you. What I'm trying to do is to simplify my logic about 'detect ...
7
votes
1answer
100 views

Recursive function to get unique properties

I just wanted to share my newly created JavaScript code. This code is responsible for passing back only the unique elements for a given array. This one is quite useful when you have a huge array and ...
7
votes
1answer
57 views

Apply arbitrary action during recursive generator function

I've got this recursive generator function. It will traverse an object looking for "leafs", any keys that don't point to sub-objects. Then it applies one of two actions on the leaf and yields it. Any ...
7
votes
1answer
674 views

Merge Intervals in JavaScript

This is a task taken from Leetcode - Given a collection of intervals, merge all overlapping intervals. Example 1: ...
3
votes
2answers
96 views

Health Test App, It Returns a Score Based on the Answers Given

Here is my parent component: App.vue. I was wondering what improvements I could make to the code here. Application Description This application was built off the Vue.js framework and utilizes a ...
6
votes
1answer
61 views

Border Radius Preview Tool

I am running through an app idea to help improve my knowledge of Javascript. The code attached performs the following: Performs a regex on the input field to check it is value 0-9 If not, it clears ...
6
votes
2answers
165 views

Turtle Doodle (my first web app)

Turtle Doodle presents several panels which arrange themselves responsively. There is a canvas where the Turtle will move, leaving a paint trail behind him. A control panel allows various commands to ...
2
votes
1answer
140 views

Given time intervals determine if a person could attend all meetings

The task is taken from LeetCode Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] ...
4
votes
2answers
315 views

Process strings of operations

This was the task (I don't know the exact wordings anymore): You get a string with operation as input: if it is a number push it to stack if it is "DUP", then duplicate the one one top ...
-2
votes
1answer
43 views

I was given an assignment on writing a javascript ES6 program for vehicles. Am I writing this correctly? Any advice or tip? [closed]

I'm taking an online course in website development and we're going over JavaScript ES6, but my professors lecture and notes I've taken we're not very helpful more resourceful with the assignment I was ...
4
votes
1answer
121 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 ...
2
votes
1answer
48 views

Rendering JSON arrays of unequal length as a table

I have a website where my users can create "table-like" layout dynamically. So imagine that my users can upload a text document, and then append columns to the document, and the output will then be ...
8
votes
3answers
674 views

Weapon class firing logic in JavaScript

I'm making a program to compare Borderlands 3 weapon damage over time in a graphic. There's still some work to be done, like implementing elemental damage, but I'd like to know if I'm doing a good job ...
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 ...
7
votes
2answers
187 views

eCommerce Mockup App in JS

I have completed this mockup eCommerce app using Javascript. This version can add products into a shopping cart and automatically calculate the order summary in the shopping cart. It can also delete ...
5
votes
2answers
212 views

Blackjack game: Count Hand Value method

I am almost completing my BlackJack game in Javascript. But I realize that there must be a way to improve the performance for these two methods. Any pointers? ...
1
vote
0answers
26 views

Promise-based AJAX calls base class

I am more than willing to use both a Promise library and an AJAX calls one if the situation calls for it. This base class sits at the very bare bones of my system and it needs to be done right. My ...
4
votes
2answers
113 views

An ES6 array of numbers - Double last number, delete the first number

I'm writing a JavaScript function for an array, based on a geographic sequence. \$[1, 2, 4, 8, 16]\$, etc. This function needs to populate the next number in the sequence $$item_n = item_{n-1} * ...
6
votes
3answers
756 views

Secret Santa pair allocator in JavaScript

I have a Secret-Santa gift swap with my family and we always forget who we had last year and never find time to do it so I wanted to create a simple web app to manage the whole thing. What I'm looking ...
3
votes
1answer
934 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 ...
4
votes
1answer
50 views

JavaScript HTML DatePicker

I'm still new in javascript and learning. I want to create a date picker using html and javascript. Below is what I have tried and it's working, so my question is "how can I do it better?" My idea is ...
3
votes
2answers
81 views

A basic trivia app

The app grabs 10 questions from an API, displays them one by one with 4 multiple choice answers. These answers are clickable buttons that alert to whether the answer is correct or not. Finally the ...
6
votes
1answer
67 views

A node CLI to start new projects

I was annoyed to manually start new projects each time so I made a Node CLI that automate the process. I'm really not comfortable yet with node, so I wanted some advice. It works but I don't know if I ...
1
vote
1answer
74 views

Flattening the nested Objects

The original idea behind the problem is that the API I'm working with returns one type of a response for GET, and requires another type to do ...
3
votes
2answers
124 views

Calculate the heat flow (for radiators)

I´m a programing rookie with minor javascript skills. So I ask you for a code review since I'm not sure whether my code is ok. Short explanation of my program: I work for the heating industry. ...
1
vote
1answer
56 views
6
votes
1answer
76 views

Filter by multiple options - also only if not empty [closed]

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

Sort, slice and rebuild new object with array data

I'm using the matomo reports api to pull out some data in js. For some charts, I'm in the need to sort the array data based on inner property value ("val"), further to get only the 3 highest (Hong ...

1
2
3 4 5
12