Tagged Questions
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 ...
-2
votes
1answer
11 views
2
votes
0answers
5 views
elastic search index/mapping creation
Including the full module, but the method I'm interested in is createIndex, feels more complicated than I think it should be. Still new at both node and elasticsearch
...
2
votes
1answer
21 views
Beginner FizzBuzz solution
Is this a bad solution to the FizzBuzz thing?
I decided to make it print "Fizz Buzz" for the numbers divisible by 3 and 5 just for practice/understanding.
...
0
votes
0answers
10 views
Filter nested array of objects with object property
I am filtering array of objects with object properties provided by the user. The goal is to return an object property 'label' by matching the property 'value'. 'input' provided to the function can be ...
2
votes
0answers
34 views
Web based Simon clone
I wrote a Simon clone in JavaScript, HTML, and CSS. It's extremely simple, but turned out fairly well.
I'm looking for general feedback, as well as these things specifically:
I opted to try to do ...
1
vote
0answers
21 views
JavaScript to connect to Redis using Singleton
I'm trying to create a class to connect to Redis in Express. I don't think my code is good enough as I got variable db hanging out.
...
-4
votes
0answers
21 views
desparate TicTacToe please [on hold]
I'm building a Tic Tac toe game... but I can't figure it out how to use the function addEventListener and if that is the only problem in there. I've seen some tutorial, and mostly of them use onclick ...
0
votes
0answers
12 views
Sending file[type=“file”] multiple content as list of base64's
There is a code that takes all files from input of multiple files, gets base64 for each of them, packs to array and jsonifies it. How to simplify and improve quality of code?
...
5
votes
0answers
46 views
2D colliding disks in JavaScript (ideal billiard balls)
I am implementing a simulation of colliding disks (ideal 2D billiard balls) in JavaScript.
I follow an event-driven algorithm that avoids discretizing time; the algorithm goes as follows at each ...
1
vote
1answer
35 views
-3
votes
0answers
24 views
Replacement for if-elseif block in javascript [on hold]
I want to simplify this chain of if and else if statements. How can I achieve it?
...
2
votes
0answers
40 views
Processing keyboard input for player movement in a game
The following code is part of a game I am making using the Phaser framework; the game is in the style of a top-down RPG, with the player moving their character in four possible directions using the ...
1
vote
2answers
59 views
JavaScript function which checks the count of words in a string
Task to accomplish: Made a function which counts the amount of words in a sentence.
Please don't put attention to the HTML. Is just for testing-purposes.
...
0
votes
0answers
21 views
Hierarchical Data to Graph
I am using vis.js to visualize some hierarchical data. I have created a recursive routine to add nodes and edges for each group and value in the dataset.
I feel like something already exists for this ...
0
votes
0answers
20 views
Display customer list in ReactJs using es2015 class syntax (v 2.0)
Following on from my question here, i have made the following changes as recommended by SirPython:
1. getInitialState
I couldn't make this change as it didn't work when utilising es6 classes, As ...
2
votes
1answer
44 views
Custom each method
I have developed the following method for each as a replacement for $.each, and I am considering using it in my personal lightweight js library called LIBJS.
The final version will be part of a ...
0
votes
0answers
16 views
Redux isomorphic fetch in interval
I'm not really sure if the following solution is the best fit, and I would like to know best practices when manipulating state and/or Ajax isomorphic fetch requests, in this case, in intervals.
Users ...
2
votes
0answers
14 views
Nodejs-Compass,PID,Motors-with johnny-five
I just finish coding this code which use for control robot using compass sensor with PID control to control motors. Trying to make javascript object for necessary job.
Please guide me for a better ...
2
votes
1answer
126 views
Remove the object's sibling on click
In my program below I am getting the parent node game 1 and then removing one of the two child nodes, depending on which one is clicked. I currently have two event ...
0
votes
0answers
114 views
+50
Adding and modifying HTML tags based on JSON input
I'm having a program (a client side program only which cannot use npm modules) that are getting HTML as string and need to change to content of it and return HTML string back (with modified content).
...
1
vote
1answer
39 views
Display customer list in ReactJs using es2015 class syntax
EDIT: Version 2 is now available here
I am just getting to grips with ReactJs using es2015 classes, i have just converted a simple portion of an app i maintain into react code and tried a few things ...
2
votes
0answers
23 views
Angular notification (alert) factory or directive
I am new to AngularJS and I thought of trying something simple: a notification factory that is useful for displaying actions alert messages like "Save successfully!" or "Validation errors: ...".
The ...
1
vote
1answer
33 views
Gulp task to increment a major, minor, or patch level of the version number of the last build
Working codepen: http://codepen.io/leongaban/pen/oxwLzE?editors=1010
The function below takes in user entered text through the cli: V=patch gulp build
It then ...
0
votes
1answer
45 views
JavaScript function for to find a defined element within a nested array
Following task:
You've got an array which contains parts. Parts can contain subparts. Subparts can contain further subparts and so on.
For example:
...
0
votes
1answer
22 views
Collect several API call results
Want to brush up my rusty web dev skills. I want to call the twitch API for several channels and eventually call a callback function when all results are in without using a sync call.
I didn't work ...
0
votes
1answer
28 views
2
votes
0answers
32 views
+50
Restructure of Node CORS middleware for unit test
How should one break this component down to better perform unit test on its behaviors?
Issues:
Authentication middleware component makes external request.
Must recognize preflight and final ...
0
votes
0answers
19 views
Simple channel broadcaster via NodeJS websockets
I have a system in PHP and I was asked to add some real time features. I was wanting to learn NodeJS so I considered a opportunity to kill two birds with one stone.
But after some search I was unable ...
0
votes
0answers
25 views
Binary search tree and breadth first search
I have written code to implement Binary Search and Breadth First Search in JS. Please review my code. I want to ensure Im following the best practices.
Node.js
...
3
votes
1answer
58 views
Event delegation without jQuery
I created event delegation like concept which is present in jQuery. AFAIK, event delegation is used to register an event for an element which is supposed to be added dynamically. So, in jQuery we do ...
3
votes
2answers
48 views
Count calls and update table accordingly
This is literally the first time I've ever used JavaScript so I know it's really bad and how to improve it just not how to implement it. Basically, I need to loop through all the elements instead of ...
3
votes
0answers
24 views
Count groups of open cells around a cell on a grid
Consider a 3x3 square surrounding a cell (marked @) on a grid:
0 1 1
1 @ 0
1 1 1
I need to find the number of groups of open cells (ones) surrounding the center ...
0
votes
3answers
56 views
Minimum element in a sorted rotated array
A sorted array [0,1,2,3,4,5] when rotated n times (3 times in this case) becomes [3,4,5,0,1,2], meaning elements in the front move to the end. The code below finds the minimum element in this array, ...
1
vote
2answers
114 views
Show/hide text field depending on select option
I'm new with JavaScript and need your advice. The idea is to show/hide text field depending on select option. I have a working code, but I believe it could be more readable and better. What have I ...
0
votes
1answer
53 views
PageVisibility API, to handle page/tab visibility changes
Currently, I'm working on a project where I needed to run some code everytime the page is hidden.
I searched high and low and found this question: Is there a way to detect if a browser window is not ...
-1
votes
1answer
41 views
0
votes
1answer
45 views
Calculating an object's stopping distance
I'm trying to smooth the movement of a cursor which has a set acceleration and max speed. I wrote this function to calculate the stopping distance of an object given its speed and acceleration, and it ...
2
votes
0answers
28 views
Weather Application - Reavling Module Pattern
I'm trying to practice and learn design patterns, and I decided to create a weather app using the revealing module pattern. How can I improve on this, and what mistakes did I make?
Main.js
...
1
vote
0answers
15 views
jQuery templating with ES6/ES2015 template strings
I have been using a particular pattern over and over again when I want to keep my jQuery apps more safe from XSS. I do something like this. (It uses ES6 template strings)
...
2
votes
1answer
29 views
Using fetch() and a new Promise object to get API results
I've written an ES6 function using the new fetch() API and returning a new resolved promise with a data object or a rejected promise with an error subclass.
I'm pretty new to both ES6 and Promises, ...
1
vote
1answer
20 views
Promise.spread “Polyfill”
I have written this "Polyfill" for Chrome's Promise object and I have some concerns about the implementation;
Does it actually work as designed? It seems to work ...
-1
votes
0answers
9 views
Using an object to keep track of rooms and the users within them, for socket io
I'm using socket io. I need to keep track of rooms and the users within them as users leave and join. I've come up with this, is there a better more efficient way performance wise? Many thanks! :-)
...
2
votes
3answers
85 views
Javascript Ownership Cost Calculator
Javascript newbie here. I built a total cost of ownership calculator to calculate the cost of a business over 5 years. It has a lot of repeating script and prob way more congested than it needs to be ...
6
votes
2answers
120 views
Beginner's Calculator code
I am trying to learn AngularJS as a start to my revival of learning, I think that I am getting the hang of it so far, but would like to see what I can do differently with some super simple ...
0
votes
0answers
20 views
Event Delegates using IIFE or Module
I am learning jQuery/JavaScript best practices and am attempting to put them into practice. My overall goal is to have lots of small, independent .js files which contain specific functionality and ...
0
votes
0answers
14 views
Light-weight JavaScript VC Framework
I've always been frustrated with js frameworks in that they require you to learn a lot of custom syntax (ie angular). Typically also they tend to include a lot of extra baggage that takes away from ...
3
votes
1answer
43 views
Simple console directive, revised using provider
I recently created my first directive based on jQuery plugin and I asked for review here: Angular console like window - first directive
I've edited my directive so now instead of ...
1
vote
1answer
47 views
Converting an SVG polygon path from relative to absolute coordinates
This question was moved from StackOverflow as suggested by some users.
I developed a function that aims to (should) provide a simple and effective method to transform a polygon ...
2
votes
0answers
31 views
Node my Chatter
In an effort to teach myself Node.JS and truly delve into its communication capabilities, I elected to recreate a previous chatting project. It took a bit of forethought to acclimate code to the ...
3
votes
0answers
45 views
Slow multiplication in a modulo
I am willing to get a linear output of a product in a ring Z/nZ
For that I have successfully implemented a code that does a Product in a modulo
However, it is not optimized to output the steps ...