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 ...
-5
votes
1answer
30 views
Shortening form id and input id
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
53 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
30 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
57 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
42 views
Printing staircase revisited
What can be more elegant ways to solve the given problem.
#
##
###
####
Code:
...
1
vote
2answers
54 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 ...
0
votes
1answer
25 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
28 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:
...
0
votes
0answers
16 views
Firebase Sign In/Sign Up Methods - React Native
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
57 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
25 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
40 views
2
votes
2answers
40 views
Implementation of insertion sort in JavaScript
I have written an insertion sort algorithm in JavaScript:
...
0
votes
1answer
64 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
33 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
33 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
25 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
42 views
JSON API client to manage user accounts
I have the following class in Typescript (using the Aurelia SPA-framework).
...
3
votes
2answers
40 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
53 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
13 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
52 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
20 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
34 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
70 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
71 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
361 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
60 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. ...
-1
votes
0answers
27 views
MySQL security in node.js client/server [closed]
This is a little project I've been working on for a while, as I learn javascript, I believe I've got it to a good first version, but would like an opinion from someone who knows javascript more.
...
3
votes
1answer
118 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 ...
2
votes
2answers
54 views
Reading genetic data in VCF and Tabix formats using an asynchronous library
I'm working with an open-source library for processing and parsing genetic data in VCF and Tabix formats. It contains functions and classes that make it easy to read an index file (a Tabix) and load ...
3
votes
1answer
57 views
Input-reading library for Node.JS
Recently I have been busy with nodejs and I thought to create something like this Java input library, so I started with some rough code like below:
...
11
votes
4answers
825 views
Gallery of employees with dynamic filtering
I'm trying to learn how to write better, more efficient JavaScript code and wanted to run this function I'd written by you and see if people can suggest an improved method.
It's basically a people ...
7
votes
1answer
108 views
Make Simultaneous HTTP Requests That Resolve Into a Single Return
This week, in an ongoing job search, I was tasked with the following pre-screening question:
Make two simultaneous http requests. Use the language and library of your choice. Make sure the results ...
6
votes
3answers
210 views
Use functional-programming to convert a tree of parent:children objects to array
Having some trouble with a code I'm trying to refactor, where I need to go over a 'tree' of items, filter some invalid items, and create a new array of filtered items which takes properties from both ...
1
vote
1answer
48 views
Countdown module that hides an element when a specified date is reached
I have the following piece of code which hides an element when a specified date was reached. I would like to get some tips about do's and don'ts.
Specifically, I'm interested in:
improvements ...
8
votes
1answer
475 views
Bot for Spacewar PPCG KotH
I wrote a bot for a Programming Puzzles & Code Gold King of the Hill type of challenge called "Spacewar!". The challenge was written by @El'endiaStarman. The bot is called "Spy".
The controller ...
0
votes
0answers
25 views
What do you think of this pattern to iterate over Objects and return a new Object? [closed]
This function merges multiple objects that only contain strings into one new object. If a key appears more than once it concatenates its values.
The objects that the function has to handle store css-...
3
votes
0answers
43 views
Linear finite state machine in ES6
I would love some feedback on my linear finite state machine. I say linear, as it can only handle one state at a time.
I am also giving my method of how I -work- with the state machine, as I would ...