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 ...
-1
votes
0answers
5 views
Could someone please provide an example of LARS algorithm via R program?
Could you tell me the best recourse about Least Angle Regression with implementation in R program, because, there is nothing on YouTube.
1
vote
0answers
13 views
Colour-matching game
This is a game about matching the right colour. In the first level you start with 3 cubes that each have a different colour. After 2 seconds the colours of the cubes disappear and the cubes become ...
3
votes
1answer
22 views
Upvote/downvote toggle
I'm sure there is a better way to implement this feature. I am making an app that allows a user "upvote" or "downvote" a post. Right now, the code works and disables the upvote button if pressed and ...
0
votes
0answers
6 views
Form validation functional javascript code
Here is a code posted originally on stackoverflow but better suited here as I was suggested.
I recently converted a code to what I think is partly at least, functional javascript.
It's a web form ...
5
votes
2answers
47 views
Test if a string is a palindrome
I got this out of an article on interviews / code challenges. The challenge text goes like this:
A palindrome is a word, phrase, number, or other sequence of
characters which reads the same ...
1
vote
1answer
12 views
3
votes
1answer
46 views
A String.prototype.diff() implementation (text diff)
I just had the idea to develop an algorithm to calculate and highlight the difference between two strings. I know that there are already some libraries to do the job but i just tried to make my own. I ...
0
votes
0answers
8 views
Mini school database with JS revealing module pattern
I tried the module pattern for the first time, with this exercise as a problem to solve: http://exercism.io/exercises/javascript/grade-school/readme
It's a small exercise requiring simple tasks :
...
1
vote
3answers
45 views
Toggling image sources
I have a set of images with class = tt like so:
<img src="images/arc_unselected.png" title="Arc" class="tt" />
and I ...
-3
votes
0answers
10 views
2
votes
2answers
34 views
Retrieve data from json file and avoid HTML/JS tight coupling
I am retrieving data from a json object and even though code works I am not sure if I am following best practices.
In particular some of the objects seems too deep (like value.metadata.connections....
-2
votes
0answers
32 views
WebRTC video chat application
I have written a basic video chat application in WebRTC. The source code is [here]]1.
So far so good. I am able to stream video but would like it if the code was better. I am using setTimeout to wait ...
2
votes
0answers
34 views
Animation with JavaScript and Sass : Neon light banner
After reading a bit about CSS3-text-shadows and seeing a few advanced examples I had the idea for a "neon light"-banner. Next idea was to animate it.
Finally it has become a mixture between a Sass-...
2
votes
0answers
35 views
Selenium WebDriver test for Slack
I submitted this script as part of a interview process. It was rejected and no reasons were given. I'm wondering what parts of my script were unacceptable. The script works, and satisfies the question,...
5
votes
1answer
97 views
A “todo” app built to practice Object Oriented JavaScript
I built a small "todo" app with an object oriented JavaScript approach.
I have spent this morning reading on a few ways to approach this, and I've come up with the following:
...
3
votes
0answers
72 views
JavaScript Singleton Pattern/Class “Methods”
I have a library that will be called in multiple places. Here is my implementation:
var vessel1 = new Vessel();
var vessel2 = new Vessel();
...
5
votes
0answers
33 views
Baseball player statistics controller
I'm somewhat new to JavaScript and Angular and read in Crockford's book that the hoisting function declaration can lead to issues. Any pointers on how to structure my file would be much appreciated.
<...
1
vote
0answers
26 views
Checking main checkbox checks all child checkboxes
I found an interesting question on Stack Overflow. It involves having two main checkboxes and 4 checkboxes for the 2 main checkboxes group.
I'm new to React and wanted to try this with React. I have ...
-3
votes
0answers
27 views
5
votes
0answers
46 views
HTML page compiling LaTeX code to nice mathematics display - 2nd attempt
I have this page that allows a user to quickly compile \$\LaTeX\$ code into a mathematical display. Whenever the user compiles the code, that page also generates an URL from which it is possible to ...
2
votes
1answer
106 views
Retrieving the lotto numbers - Node.js
I'm looking for feedback as to how I've structured the async calls, and If anything should be written differently.
endpoints.js
...
5
votes
3answers
161 views
+50
Flatten an array
I have got this interview question which has asked me to write a production level code which flattens the arbitrary nested array of arrays.
Code
...
1
vote
1answer
47 views
Sorting and update 2D Dimension
Question:
Compare and update the inventory stored in a 2D array against a second 2D array of a fresh delivery. Update the current existing inventory item quantities (in arr1). If an item cannot be ...
3
votes
1answer
44 views
Basic arithmetic calculator in JavaScript
Task is basically:
"Write a function which takes two number as the first two parameter. The third parameter is one of the arithmetic operators (+ , - , * , /). Execute the arithmetic operation (...
1
vote
1answer
26 views
Using JavaScript-bitwise AND and -bitwise NOT for setting a number to 0
Obviously is the XOR-operator is used in low-level programming-languages used a lot for setting a value back to all bits 0.
For example:
11010 ^ 11010 => 00000
Brought my teacher to figuring a out ...
1
vote
0answers
15 views
Matching a current user's “liked / followed” items with results from a search query
This is pretty ugly now. My main objective is to perform a search query, which I do via mongoosastic / elastic search (the search paginates 12 items at time). Then, I want to match those results with ...
0
votes
0answers
18 views
Database to calculate Date/Time [closed]
I'm trying to make a calculator to calculate the estimated delivery time for products from its producers, and since every producer has his own time cycles, I have to make a kind of database about them ...
7
votes
1answer
57 views
RPG Stack Exchange chat bot
Recently, I made a small bot to simulate an ASCII-based RPG in a chat room. The other users can enter commands (.left, .right, <...
1
vote
1answer
27 views
Using promises to GET and process data
I'm working on a Meteor application which integrates a user's contacts from external sources (Google in the case of this example). I'm currently writing the server side code to retrieve this data and ...
3
votes
0answers
70 views
HTML5 canvas snake game
My most recent project is this simple snake game, and I would like to know what you guys think of it and if you have any suggestions. All feedback is welcome, constructive criticism is appreciated.
<...
3
votes
0answers
37 views
Join arrays of objects by some identifier
The following is some JavaScript that I wrote to join two arrays of objects by an identifier. The goal is to extend the objects in a1 to include the extra fields in ...
0
votes
0answers
13 views
ENOBUFS when creating to many sockets with socket.io [closed]
What I am trying to do:
I write a node.js client/server application which uses persistent websocket connections (no longpolling). I want to stress test my server in order to tune it's performance and ...
8
votes
1answer
108 views
+100
Animate and play sounds in Simon Says 'the Angular way'
I am a newbie coder and I'm trying to learn good coding habits. I'm making a Simon Says game challenge from Free Code Camp in Angular JS.
Codepen
I have an array that keeps random integers between ...
-2
votes
0answers
11 views
Auto-filling text field using JS/HTML [closed]
I am trying to create a bookmark that will auto fill a text field of a webpage. However; I'm receiving the following error code:
(program):1 Uncaught TypeError: Cannot set property 'text' of null
...
0
votes
1answer
39 views
Simple login using ReactJS
I have successfully implemented a simple login page using ReactJS by coding it all in JavaScript (a flexibility that I like) but I am still a beginner in React and would like to know whether this is ...
2
votes
1answer
30 views
A utility class for fractions
I've been working though Project Euler problems using JavaScript, and along the way I've found it useful to create "classes" for different types of numbers (like an integer that can be arbitrarily ...
3
votes
0answers
97 views
Jarvis the discord.js chat bot
Just finished creating my first bot using Discord.js for the chat application, Discord. This is my first bot and first javascript program I have ever created. I'm mainly interested in ways I can ...
3
votes
1answer
89 views
+100
Form validation library
Background:
After reading this thought provoking book I decided to write a small library as an exercise.
...
0
votes
0answers
26 views
Loading an animation with an Ajax request
I am not sure if this is the correct way to make an Ajax request and do the typical loading/processing GIF/animation while processing is happening and displaying the response.
HTML:
...
3
votes
1answer
66 views
Basic Nim game vs computer in JavaScript
This is my first time writing a basic program/game in any programming language.
It is supposed to a be a Nim game vs a computer with these basic parameters:
Use ...
4
votes
2answers
91 views
Calculating quiz score, with weights and partial credit
There is a quiz-game with simple rules. You have to guess one of three options. Each option has a particular weight, for example:
Option 1: 20 points
Option 2: 30 points
Option 3: 50 points
If ...
3
votes
1answer
39 views
Reactjs Tab Component
I made a simple bare bones Tab component, i'm a beginner when it comes to ReactJS so any advice regarding the codes functionality is greatly appreciated.
Tab.js Component
...
0
votes
0answers
22 views
Modular JS revealing module pattern
I am just getting started with Modular JS and I am converting a spaghetti coded jQuery UI using the revealing module pattern.
My concern is, basically, if I am doing it right.
tab_template:
...
3
votes
0answers
34 views
Tiny Image Editor
I made a small(ish) image editor for a client that is supposed to be able to do the following:
initially scale image to preset size to avoid tiny/huge images
initially center image in canvas
resize ...
2
votes
0answers
15 views
Function to grab all windows and nested windows on a page
I wrote the following function which takes in a window and returns all nested windows on a webpage (I can get all the windows by calling the function with window.top). Is there a more elegant/...
0
votes
0answers
13 views
Add and merge 2D array items so no nested duplicates on the outer array
this.collisions is a 2D array containing a list of collisions that, when bodies collide, they should be added to it. Here's an example:
...
2
votes
1answer
25 views
JavaScript image-Carousel with using IIFE
I have to implement an image-Carousel.
Because I'll reuse the snippet within other projects which might contain all kinds of external libraries I used an immediately invoked function expression.
...
1
vote
1answer
20 views
Sidebar menu to hide or expand parts of a form
I have some of my code that I have tried to improve on to make it cleaner and efficient and I would like some feedback to see if I am going in the right direction with what I am trying to do.
I have ...
1
vote
2answers
130 views
Tasks organizer app
I've created my first complete JS app, which lets you add tasks and control how much time you spend on them. I posted this to get some ideas how to improve readability, efficiency and the speed of my ...
1
vote
1answer
58 views
Handling post-registration action
This code is Express NodeJS code that handles post registration .post action where the user must select a custom username. The username is validated, and if valid, ...