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
12 views

Filter Options in React

I have several products. A product can have 1 or more images. In each image, we have content slot. I don't want duplication per content slot in a product. My code works fine. I'm just wondering what ...
6
votes
5answers
218 views

Extracting a part of a URL path

I have a string like the one below from which I am extracting the tariff name. ...
0
votes
2answers
66 views

Processing list of users- filtering out from refused list

The code below takes a list of users and displays two lists Refused users Admitted users Sample output: Refuse: Phil, Lola. Admit: Chris, Anne, Colin, Terri, Sam, Kay, Bruce. Any feedback is ...
0
votes
0answers
34 views

Chaining JavaScript functions and properties to make code cleaner [closed]

So I have a situation where I need to check some stuff and depending on the outcome possibly disable a select element and change the value of the default option. Part of the code is this piece, which ...
3
votes
2answers
83 views

Tic Tac Toe in object oriented JavaScript

I've been working on a course assignment for 'The Odin Project' and was hoping to get a review of my code. As per the help guide, the code is fully functional. The criteria for this was pretty ...
3
votes
2answers
268 views

PHP blogging application with AJAX loading

I have been working on an online newspaper/blogging application with CodeIgniter 3.1.8 and Twitter Bootstrap 4. The latest feature added is lazy loading of posts. From the Static_model (...
3
votes
2answers
155 views

Check for max value in stack

Got this problem in a coding interview - Get the max value of a stack in O(1). The stack contains numbers only. Please review my solution. ...
0
votes
1answer
47 views

custom array sorting algorithm

So I came up with a "new" sorting algorithm: ...
2
votes
1answer
81 views

Learning asynchronous caching by implementing one

After implementing a serial CLOCK second-chance cache in C++ without having enough rope to shoot myself in the foot, decided to dive into Javascript through NodeJs and write an asynchronous one. I ...
1
vote
2answers
51 views

Javascript - On mouseup check if any of the parents has/includes specific id

On my page I have a mouseup eventlistener on document. I want to be able catch if the clicked elements has a specific ...
2
votes
2answers
71 views

JS script fetching GitHub API for personal website

I've built a very simple personal website, everything is in a single file because it is very straightforward, but I think the JS script could be better structured. All it does is fetch some repos from ...
1
vote
1answer
78 views

list of games to open radar match in iframe on for drop-down controls

In general my page is slow and has several points in the code that I believe can be improved, even in relation to the structure used. Anyway, the biggest problem is: The page I'm creating is very ...
3
votes
2answers
127 views

Single user Electron application allowing basic CRUD operation on a table (stored in JSON)

I am completely new to JavaScript and I will be grateful for your comments on my Electron app (electron is a JS framework allowing to create of desktop apps). I needed to create an application that ...
1
vote
1answer
57 views

Recursively access deeply nested object

Problem Statement I need to access a deeply nested object. I could've used a 3rd party util such as Lodash but insisted myself on writing a Vanilla JS solution with a recursive strategy. Code Can this ...
3
votes
2answers
148 views

How to implement a 2D Cellular Automaton in JavaScript?

So far I have this: ...
1
vote
3answers
117 views

Run-length coder

I have this code, which counts only adjacent letters in a string and returns the count of each letter. ...
4
votes
2answers
138 views

File naming (two files cannot have equal names)

This is a challenge I completed at CodeSignal. You are given an array of desired filenames in the order of their creation. Since two files cannot have equal names, the one which comes later will have ...
3
votes
2answers
61 views

Limit second <select> options based on the first <select>

I want to see if there's a better way to write this code, solely in Javascript. There are two kinds of sets, the first set (C7, T7, C11, T11) have four options in the first select, and then up to two ...
10
votes
4answers
1k views
2
votes
0answers
44 views

Custom HTML Element with scrolling text

A junior developer here. I wrote a simple javascript custom element code here: https://codepen.io/rndbox/pen/mdWxryw as clean as I could with some advice from Junior Vs Senior Code - How To Write ...
5
votes
1answer
271 views

JavaScript discrete slider web component

The standard HTML range input element suffers from a number of limitations that caused me to implement the web component presented here. First, it is unnecessarily complicated to style the standard ...
2
votes
1answer
270 views

To-do app front-end in Vue 3

I have put together a To-do Application with the Slim framework on the back-end (API) and a Vue 3 front-end. I added a demo on my YouTube channel. In the main App.vue file I have: ...
3
votes
2answers
59 views

concise way to build an object from an array of objects

The following code is working as expected but I'm wondering if there's a way to use Object.assign, or some other approach, to build the ...
4
votes
2answers
561 views

Vue.js checkout stepper

I have made this small checkout stepper with Vue (v 2.x.x): ...
3
votes
1answer
143 views

Node backend to run user-submitted code in a virtual machine

As per the title, I'm making a webapp that is intended to use as a JS exercise platform. Problems are shown to users, they submit code, that code is run against a few test cases, and a report of the ...
2
votes
1answer
98 views

JavaScript copy-to-clipboard class

I am have made a small copy-to-clipboard script. I have made a method called copyToClipboard that does the following: create an input box; read the content of an ...
4
votes
1answer
73 views

Javascript Pub/Sub

Here is a short pice of code that suppose to work as Pub/Sub or EventDisptacher of some sort. I only do code in JS a few times a year, so hence I'm asking for your time. Right now I'm working on ...
4
votes
1answer
150 views

Randomly rearrange table rows without unnecessary reflows

I recently completed a coding challenge for a company that did not get me to the next stage. They were kind enough to provide the following feedback: The coding assignment does not match what we are ...
2
votes
2answers
40 views

Combine data from array of objects

I got this data structure and I am checking to see which properties are true, then I am adding the key for all the properties that are true to that object on a new ...
1
vote
1answer
60 views

A (deep) cloning method for ES-Objects

I have written a (recursive) deep clone method for ES/JS-objects. It seems to work fine, but maybe I'm missing things. Please, feel free to comment! Note: the method will not clone cyclic structures. ...
3
votes
1answer
33 views

Get default value from query params + repeating code

The main goal of this task is to take values from the query parameter and put it in inputu. The first problem is that I don't know much about how to do it so that the code doesn't repeat itself and I ...
1
vote
2answers
96 views

Recursively find data in array of objects

On this script I look up properties in an array of objects. There is an original array of strings list to get the objects that match the ...
2
votes
1answer
55 views

Iterating through a list to generate calendars

I'm iterating through a list to generate calendars, the issue is each generator function has the same this.addToCalendar() function. I'd like to know how I could ...
2
votes
0answers
36 views

Weather app using es6 modules

i have recently built this simple weather-app. I would be happy to get some criticisms to improve my code. Structure: app.js: ...
1
vote
1answer
48 views

Learning Javascript OOP with a Collapsing Item Class

I'm trying to get into object oriented javascript programming. I have written a class for collapsible elements as a test. These elements all have a certain class and no matter how many elements there ...
1
vote
1answer
368 views

Add / Overwrite an object in an array

I am trying to overwrite an object in an array if the title property exists, otherwise just push it to the array. I found two approaches and I wonder which one is ...
5
votes
1answer
137 views

JavaScript: A drawing program in OOP

I made a little drawing program in OOP. The game consists of a canvas which is basically a 2d array where the user can draw various shapes on it. There can be multiple shapes overlapped on top of each ...
5
votes
1answer
109 views

Generate all partitions of a set of items

Here are the items: var item = ['a', 'b', 'c', 'd']; Desired output: ...
0
votes
1answer
180 views

Import XML files to MongoDb with Nodejs

Here is my code which will read XML files and import the data to MongoDb. Do you have any comments on my code? ...
1
vote
5answers
151 views

FizzBuzz solution

I'm preparing for junior developer interviews and am trying to come up with a more interesting/versatile solution to FizzBuzz than I've done in the past. Do you have any ideas of how I might DRY this ...
0
votes
2answers
45 views

Looping Array object with conditions and comparison the performance with ECMA VS Vanilla JS

The Plain vanilla JS needs to converted in to advanced ECMA. The below 3 snippets shown yields the correct result. Need to identify which among them is performance oriented ...
2
votes
1answer
48 views

Countdown Timer evaluation

Please consider evaluating the code below for best practices, efficiency, and mistakes. I got some of the code from W3 schools (I know, I know, but they've come a long way) and assimilated it to what ...
0
votes
3answers
89 views

function to get input group for user

I got tasked with writing a page that will add as many profile entries as the user wants, and web programming is not at all my field. There are multiple input groups but I'm just using the "age&...
0
votes
1answer
43 views

Avoid the object/array check and treat the return value the same way with JavaScript spread operator?

I'm trying to implement a function (a template-helper function) which provides a simple merge-like functionality for both arrays and objects. The two functions are basically looks identical: ...
1
vote
2answers
189 views

Create a simple hangman game using OOP and Javascript

I had a task to create a simple hangman game using O.O.P. with Javascript. It had to render the puzzle and remaining guesses to the DOM but didn't require any C.S.S. This is what I created. This is my ...
1
vote
1answer
46 views

Filtering Array Based on Element Values

Required to splice specific element value in an array based on the condition. Both the below code does the same job and yields the correct results. But couldn't figure out how to reduce coding ...
0
votes
1answer
73 views

Transform this to one line arrow function ES6+

I am using one line arrow functions a lot, if they are well written I believe they can make code easier to read. I believe that the following code can be easily transformed into one liner but I can't ...
3
votes
2answers
828 views

A better solution for nested maps

I'm trying to build a nav, but the way I currently have the data setup I'm having to map within a map with a map to get all of my data out - I have a feeling that this is a poor way of doing something ...
4
votes
3answers
394 views

Microsoft OA | Longest Substring Without 3 Contiguous Occurrences of Letter

For the following question, does my JS Solution seem correct? I'm looking for some peer review. Q: Given a string s containing only a and b, find longest substring of s such that s does not contain ...

1
2 3 4 5
14