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
0
votes
0answers
16 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 ...
5
votes
2answers
106 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
58 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
33 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
60 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
115 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 ...
4
votes
2answers
201 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 ...
4
votes
2answers
110 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 ...
2
votes
0answers
40 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 ...
1
vote
1answer
31 views

Adding values to FormData - javascript

...
2
votes
1answer
65 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 ...
5
votes
0answers
90 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
98 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. ...
0
votes
1answer
20 views

Bidirectional numeric (floating point) sequence iterator

I wanted a neat iterator that will always give me neat sequence of step spaced numbers. This is what I came up with, but I am a bit skeptical that I covered all ...
4
votes
2answers
133 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 ...
6
votes
2answers
146 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
39 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 ...
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 ...
2
votes
1answer
65 views

Loading KML files into leaflet Javascript map

This is working code for input KML files into leaflet map ...
8
votes
3answers
656 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 ...
8
votes
1answer
240 views

“Block a website” script with vanilla JavaScript

I use this script to block access to a one or more websites with vanilla JavaScript. I find that it helps me avoid some addictive news websites that make me depressed. (Credit to Marat Tanalin for ...
1
vote
0answers
25 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
108 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} * ...
7
votes
2answers
163 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 ...
6
votes
1answer
120 views

Simple input class change with vanilla JS

I am just testing how I solved simple stuff. Goal: The aim is to expand the width of an input and collapse it. When mouseover ...
3
votes
2answers
66 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 ...
1
vote
1answer
68 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 ...
4
votes
1answer
46 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 ...
8
votes
5answers
736 views

Expanding powers of expressions of the form ax+b

I solved the following problem: Write a function expand that takes in an expresion with a single, one character variable, and expands it. The expresion is in the form ...
1
vote
1answer
56 views

Finding the objects with the cheapest seats

i have the following json object ...
3
votes
2answers
94 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 ...
0
votes
0answers
23 views

Multiple animation control using Vanilla JS ES6

What I'm doing Divide members into five section, and apply animation for each member to reveal at first. When I click the section, it is expanded to whole viewport and introduce detail about ...
4
votes
1answer
69 views

Event triggers for animations using vanilla ES6

I'm new to JS and wanna know right code style or approach to cod Vanilla JS using ES6. To practice this, I'm using ESLint JS code-style of AirBnb and referencing clean-code-javascript repo. However, I ...
0
votes
0answers
41 views

How to filter URL from the array list based on the string name with regExp?

The solution found to filtering pathname with customising current normalizeTme() function. For sure it is not the ideal way of ...
4
votes
2answers
77 views

An Express route, which renders a page, and makes use of socket.io

This is the code for a basic endpoint in my express app routes folder. This firstly renders a page, and then on a continuous loop, renders information about some random "Breaking Bad" character. The ...
4
votes
1answer
78 views

Pivotting SQL Table Response to JSON in JavaScript

Issue Our API returns two formats JSON and this SQL table format. I'm not sure what it is truly called so I'll give a few examples below. Like all API responses, it can be a list or a single response ...
6
votes
1answer
55 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 ...
4
votes
1answer
109 views

Pulling data from the GitHub API for user repositories

I'm looking for specific feedback on a major design change that I plan on making to my personal website (https://aleksandrhovhannisyan.github.io/). Currently, the Projects section contains hardcoded ...
4
votes
1answer
52 views

Triggering a callback when user put in the Konami cheat code anywhere in the page

I wrote this just for some fun and also to practise my ES6 skills. When user key in the Konami Cheat Code(⬆️⬆️⬇️⬇️⬅️➡️⬅️➡️🅱️🅰️↩️) anywhere in the page, it should trigger a callback. In the following ...
0
votes
0answers
24 views

Details/Dropdown toggler

I haven't had a great deal of time to build components using some of the more fun items that have come since ES6+ started hitting the scene, but figured I'd share a dropdown snippet I created and get ...
2
votes
1answer
46 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 ...
4
votes
2answers
73 views

RegEx version control

this is my first time on this stack exchange :) I created a little script to check for the latest version of specified API version available, but I am wondering if I am using the best way possible ...
3
votes
3answers
49 views

Simple javascript code to create an image caption

I'm trying to become better at javascript and have written a simple script that just creates some html from getting some details from some elements (e.g. the image alt text) and inserts it onto the ...
6
votes
4answers
1k views

Find all letter Combinations of a Phone Number

The task is taken from LeetCode Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just ...
2
votes
1answer
90 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],...] ...
0
votes
0answers
194 views

Merge Two Sorted Lists in JavaScript

The task is taken from LeetCode Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. ...
3
votes
1answer
63 views

Whitelist for textarea and save input to file

I'm working with product codes, so a user can only scan these type of product codes into a textarea. I don't know if my code is written the best way possible, or has good performance. I'm using a ...
6
votes
1answer
277 views

Merge Intervals in JavaScript

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

Jewels and Stones

The task is taken from leetcode You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you ...
2
votes
1answer
93 views

Number of Islands

The task is taken from leetcode Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands ...