ECMAScript (commonly referred to as JavaScript) is primarily used for scripting web-pages but also has several embedded forms and stand-alone interpreters / JIT engines. Use this tag for questions regarding ECMAScript 5 or 6 and its dialects / implementations: JavaScript, JScript, etc., excluding ...

learn more… | top users | synonyms

0
votes
0answers
13 views

JavaScript modular framework for a large web-site

In my ASP.NET MVC project I simply inserted <script></script> into my views - it caused code duplications and spaghetti code. Now, I have decided to ...
3
votes
0answers
25 views

DRYing a stateless functional builder

This was just an experiment to see if it was possible to build a stateless builder in ES6. I was able to do it, but when I took it a step further I got stuck trying to DRY it out. In this case, we ...
2
votes
2answers
122 views

Defining an OOP structure for a Student class in NodeJS

Most of my coding experience is in C#. The way object oriented programming is laid out in C# is a bit different from NodeJS, hence this is my first NodeJS OOP for a ...
1
vote
0answers
12 views

Emulating the React.js createElement function

I am trying to create a helper function for myself, and this helper should do the following: Create an element Add properties to the element Set values to the element (this is the concern of my ...
0
votes
0answers
15 views

Angular template for a dropdown menu

I'm ashamed to ask such an elementary question but I tried to DRY up this template a couple ways and couldn't come up with anything I was satisfied with. Can you help? ...
0
votes
2answers
64 views

Looping over an array using $.each

The code below contains an array of objects that I loop over and append to hidden input fields in the DOM. As these inputs have no ID, I first select them by name using ...
1
vote
1answer
16 views

Promise Chaining for a Firebase v3 Auth Subsystem - Password Based Users

Firebase v3 Offers Authentication via 3rd party oAuth providers, facebook, github,google, and twitter. They also offer password pased authentication. Authenticated users have a firebase.User object ...
3
votes
0answers
34 views

A dice roller in node.js

I knocked out a dice roller in 2 days. I think this is the first coding project I've ever actually completed to a degree where I'm not embarrassed to post it. This is my first time working with ...
0
votes
1answer
35 views

Binary to decimal converter in JavaScript

This exercise with a test suite is from here. I did not intend to use ES6 features, it's plain old JavaScript. That's why I seek advice more on the good practices, performance side, than modern syntax....
3
votes
1answer
46 views

Ribbon animation code too repetitive

I spent the last two days getting a ribbon animation to work with divs so that I can later add li link elements to them to act as a menu. I used the progess bar animation code as inspiration from ...
-5
votes
1answer
41 views

Shortening form id and input id [on hold]

I would like to make my script more efficient and while looking at my script which is fairly large I realize thatnT.dS[v] is repeated quite often. I've tried do ...
4
votes
1answer
70 views

Javascript contact form validation code

I'm a UI / UX Designer trying to sharpen my JS skills. I wanted someone else to check this code snippet and maybe have a Pro tip to improve or shorten it. Javascript: ...
5
votes
0answers
38 views

Mocking config data in JavaScript unit tests

I'd really like someone to sanity check my approach for unit testing the summarise() function and mocking its dependencies. Background Each option has a set of ...
1
vote
1answer
63 views

Which jQuery click solution is better? [on hold]

I am here at my workplace, and we have a very passionate debate with my colleague about $().click() method vs onclick. I will ...
1
vote
2answers
47 views

Printing staircase revisited

What can be more elegant ways to solve the given problem. # ## ### #### Code: ...
1
vote
2answers
57 views

Selection sort algorithm examination

I had an algorithm test. I was asked Selection sort algorithm to program. I coded it in javascript and shown to examiner. But he was not satisfied, he said its too complicated. I think I have ...
1
vote
1answer
33 views

Angular Promise trying Wrapper

Sometimes I need to repeat an execution of rejected promises several times, for example, to fetch some data over internet. There is a wrapper, which accepts Promise and tryCount: ...
3
votes
1answer
31 views

Adding a class to a root element

I have written some ES2015 JavaScript that adds a class to a root element when one of it's immediate children is focused. Here is the markup for the code to be run on: ...
-1
votes
0answers
21 views

Firebase Sign In/Sign Up Methods - React Native [on hold]

I am in the process of updating my code to the new Firebase 3 Web API standards. I'm having some trouble getting all the syntax right and I'm not quite sure where I am going wrong. Can someone please ...
0
votes
0answers
60 views

Stack Overflow-like vote system in Node.JS / mongoose

Here, I have the logic for a "stack overflow-like" vote system and validation to protect the vote. Just wondering if If there would be a better way to refactor / make this more simple and clean? to ...
1
vote
0answers
26 views

Single request weather app using ForecastIO service

I needed a web weather for a app that talks to ForecastIO API. Basically that sent a request to https://api.forecast.io/forecast/APIKEY/LATITUDE,LONGITUDE giving me ...
0
votes
0answers
12 views

Pull GeoJSON data for an API Request [on hold]

I am using a census API module from CitySDK. I am getting an error in my javascript console. When I load the page the, no data is there. I am attempting to pull the data and display it on a webpage. ...
3
votes
1answer
45 views
2
votes
2answers
40 views

Implementation of insertion sort in JavaScript

I have written an insertion sort algorithm in JavaScript: ...
0
votes
1answer
66 views

JavaScript DOM modification

I'm thinking about DOM modification performance. In a perfect way, we alter each element but DOM modification is really heavy and alter many elements at same time froze the browser. I didn't make any ...
0
votes
1answer
34 views

JavaScript to parse json that can be, string, object and array

I have to parse a json object that can be a string, array, array of strings and array of object. I realised that it's not good from the beginning that one object can be many types, but I can't change ...
4
votes
1answer
36 views

Takes function and throws exception if passed function doesn't throw an exception

The code below is part of a toy test assertion library I've written. I'm looking for feedback specifically on lines 4 - 9. I'd like to extract them from the ...
2
votes
0answers
26 views

Factory to augment JS classes with validation methods

I have some validation classes. To keep things smooth, I create a single class that has those validation classes inside of it. That class will be a singleton, and gets injected into my other classes. ...
3
votes
1answer
43 views

JSON API client to manage user accounts

I have the following class in Typescript (using the Aurelia SPA-framework). ...
3
votes
2answers
42 views

JS cross-fade transition

As the question says....Can this be done any better? I could introduce more variables to cut down on function number, but does it make sense? So this is a simple cross-fade between two images : ...
1
vote
2answers
47 views

Simple JS validation for two contact forms

I'm not a pro in js so, my code is a mess (but it's working!). I would like to ask your help to reduce some redundancies in two cases. Those two are codes are affecting these two forms: ...
-1
votes
0answers
10 views

Fade out text, then show again repetadely in JQuery [closed]

Hey I'm new to JQuery and want my website to look nicer by having a repeated fade out effect with the text, and maybe eventually fade in also. So I set up a system that is called when Fade out Is ...
7
votes
2answers
54 views

Contra - 30 More Lives

Just for the fun of it, I wanted to have a hidden keypress function on my website that performs an event when the user types in the Contra code for thirty lives. I'...
0
votes
0answers
14 views

Polymer decorator to make iron-forms actually work

I just finished writing a first version of hot-form. It's a simple decorator that makes iron-forms do I basically always do: Show error messages, or a custom ...
7
votes
1answer
102 views

My minesweeper implementation in Javascript

I'm beginner coder and I would like to request for critique review of my minesweeper implementation. Game was made using bootstrap 3 and game board itself is a simple html DOM table. Game is complete ...
0
votes
0answers
10 views

Need to Trigger the calculation of work timings by windows lock [closed]

I have written a script in HTML using JavaScript to calculate my work time in the office. Please find my working code below for reference. In this I need to click on the pause button manually when ...
4
votes
1answer
65 views

Stack implementation in ES6

Finally happy to see that now we can have iterators and generators. I also need to try to have private properties too so that we have well encapsulated data structures and I see that there are Proxies ...
3
votes
1answer
54 views

Knapsack algorithm in JavaScript - Integer weights and values

My version of Knapsack works only when the weights or values of items are whole numbers. Restrictions You are given an array of objects each of which contains a weight and value. You are also given ...
1
vote
1answer
49 views

Interpreting the time

EDIT: Alternate answer on overflow: http://stackoverflow.com/questions/38487692/how-can-i-interpret-the-time-with-less-code/38492144#38492144 But I really want to keep Jonah's answer here too. Just ...
-1
votes
0answers
21 views

Using input from a prompt to loop through an array [closed]

I'm trying to write a function for a card game which will allow players to exchange a card in their hand for a card in their opponents'. I'm just starting out, so I know I'm running into a problem ...
0
votes
0answers
14 views

display and calculate score for javascript quiz [migrated]

i'm a teacher and have just started learning to code for making online quizzes for my students. I'm still very new to programming like JavaScript and php, and I've tried to looked for sources online ...
2
votes
0answers
35 views

Input-reading library for Node.JS part 2

Note: This code is a rewrite of the post I mentioned here since according to CR policy I cannot update the same question. This is somewhat didn't went through that much thought process and I wrote ...
1
vote
0answers
71 views

“RESTful” node.js server using express

I have attempted to construct a simple RESTful node server that allows for user authentication using passport and jwt: ...
1
vote
0answers
28 views

Site Registration Code causing multiple accounts to be registered [closed]

I have an app that uses the MEAN stack, recently I have seen a little strange behaviour. Now this doesn't happen every time a user registers, so far it has happened 3 times. When a user registers the ...
2
votes
0answers
73 views

Request Queue for League of Legends API

I am working on some website for League of Legends statistics, which uses the RiotGames API. The API allows you to do a maximum amount of requests per 10 seconds, and another maximum amount of ...
1
vote
0answers
72 views

Very basic React toDo-List

After learning a bit React in the last weeks I've decided to make a toDo-list. I've got the basic-functionalities (create, update, delete entries) finished. I'm going to enhance the app with a ...
1
vote
3answers
363 views

Bubble sort examination

I solved bubble sort in an exam, but the examiner wasn't satisfied with the solution. Please tell me why my solution is unsatisfactory. ...
2
votes
0answers
61 views

HTML5 Parallax Scrolling utility using canvas

I have created a utility to create scrolling parallax backgrounds. ...
0
votes
0answers
66 views

Saving an object using a promise chain

This here is some fairly simple functionality The user has a list of objects, which they modify, or may create a new object. When the user presses 'Save/Update' the 'saveClick()' function is called. ...
3
votes
1answer
121 views

HTML5 Snake Game

This is the first version of my first HTML5 game. Beyond the standard features, I've added a high scores board which uses local storage to keep track of the scores. You can move the snake with the ...