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 ...
0
votes
0answers
18 views
Convert JSON into Avro acceptable format
I've written a node.js command line script that takes a multi-line file of JSON and a schema template of what the object should look like, and converts it to a format that Apache Avro accepts.
...
-8
votes
0answers
28 views
What are the Possible Flaws in my Program and Suggestion For Optimization [on hold]
Here is my code, It's Java Script,
...
8
votes
1answer
71 views
Chrome extension that marks Reddit entries with clickbait sources
So, I've created my first Chrome extension! What this does is it highlights every post on Reddit that comes from a source of dubious quality. It provides a few sources by default and allows the user ...
0
votes
1answer
18 views
Module Pattern javascript to Initialize Page, add event listeners, load map
I've written a script that I would love to get feedback evaluating the following: Module Pattern implementation, robustness, conciseness, cross-browser compatibility. My goal is to eventually use this ...
-2
votes
0answers
15 views
How could I reorganize my require.js project with webpack or browserify [on hold]
I'm new to JS builder tool, I spent 2 days on organizing my js scripts via require.js
However, my friends told me that ...
0
votes
1answer
25 views
Spawning child processes and event-listening
This function scrapes data from a webpage by spawning a process that executes a CasperJS web scraping script. The spawned process outputs data to stdout.
This ...
0
votes
2answers
38 views
Partitioning an array of objects into four arrays by one attribute
I have an array of API objects, below is an example of one object:
...
-6
votes
0answers
17 views
Fnd the difference between arrays by keyword in javascript code? [on hold]
How i can improve this javascript code? https://jsfiddle.net/dmitriykupriynov/1pfzmkr9/1/
I want to find the difference between arrays by keyword but seems my solution not optimal.
...
0
votes
1answer
20 views
callback of setTimeout function when performing synchronous actions
Inside a function I'm calling playgame service, once I've obtained the needed data (gameBeingPlayed) I need to show a 3..2..1 counter and then start a game
...
-1
votes
0answers
18 views
Simplify table highlighting [on hold]
Looking for feedback on how to better improve or simplify the code below.
...
3
votes
2answers
71 views
Decimal number to binary number conversion in JavaScript
I made this decimal to binary conversion as an exercise for myself and because it is obviously often asked during job interviews / tests.
Any hints concerning possible improvements welcomed.
...
-2
votes
0answers
25 views
Assigning distinct random numbers to variables [on hold]
I'm attempting to generate non repeating random numbers between 1-5, 1-10, 1-20, etc. I'm on to the Fisher-Yates Shuffle but I'm not sure I've implemented it in the best way. My plan is to associate ...
1
vote
0answers
26 views
Iterations with asynchronous functions
I haven't really worked much with asynchronous code so I'm wondering if I am doing something wrong/something could go wrong. Right now of all the test cases that I have done, my code has worked but ...
0
votes
3answers
33 views
Keyboard handler for moving in four directions
I'm having touble deciding if I should leave the default: break; in the switch statement or not. It does kinda show intent, i.e. that most keys are not handled, but ...
-2
votes
0answers
10 views
1
vote
0answers
21 views
Producer/Consumer write to file
I'm concerned with the memory usage of this application. When I start it and look at it's memory usage while it's waiting for input, it's memory usage is around 13,212 K.
When the application runs ...
0
votes
0answers
14 views
How to load this javascript without interval [on hold]
I have create a round clock but its load more
how to solve this?
my code:
...
2
votes
2answers
62 views
+50
Driving equation output from select input boxes via JavaScript and HTML
I would like to create a simple interface to allow a user to make a few choices via select boxes and drive a resulting equation.
Here's a screenshot:
This is a gross simplification and I am ...
-2
votes
0answers
48 views
Beta login api without passwords
In present day, people are asked more & more for new and more difficult passwords all over the web. To be honest, in my case, it is becoming a real struggle to remember all those passwords and I ...
2
votes
3answers
200 views
JavaScript Iteration
In my current project I have objects of the following structure:
CanvasBundle - Object
Some elements...
gridCanvas
axesCanvas
...
4
votes
0answers
86 views
Simple wrapper for the GitHub API with Promises
I'm only just starting to delve into the wondrous world of functional programming and Promises; to start with I've converted a bunch of procedural code in (what I believe to be) is a more readable ...
2
votes
0answers
19 views
Guidance on grouping equal sets of numbers, so each group has a similar average
Goal: I am trying to build teams of 5 people. Each person has an integer elo (rank). My goal is to make all the teams as equal/fair as possible, by having the average elo of each team be as close as ...
1
vote
1answer
88 views
Characters set permutations with repetitions
The code bellow generates all the permutation(with repetitions) for given character set. Is there any better(simpler, more performant) way to do that?
...
3
votes
0answers
29 views
Implementation of Dijkstra's Algorithm in JavaScript that returns both shortestDist/shortestPaths
I decided to try to understand the basic idea behind Dijkstra's algorithm better so I implemented it in JavaScript (the only language I am proficient in as of now) so I could really see what was ...
1
vote
0answers
24 views
One class unit-tests
Its my first attempt to unit-test in Js. Not yet TDD.
What I can change?
EventsPersistancyService.js:
...
1
vote
2answers
71 views
Typing game in JavaScript
I recently made a typing game in JavaScript and I would like it to be reviewed so I can become better knowing where I made mistakes and what I should improve on.
CodePen
...
2
votes
1answer
21 views
Parallel computation to be merged, depending on single call
Steps:
Get AMOUNT from a call to API endpoint /a, e.g. AMOUNT == 5 (in the code it is set ...
2
votes
2answers
89 views
Calling multiple plugins inside script tags
I'm not that comfortable with properly writing jQuery. On my website I've used a lot of jQuery plugins and basically just dumped all the different initiating scripts between two ...
0
votes
2answers
47 views
ReactJS Static Single Page App with Routing
I'm currently trying to write an App with Cordova and ReactJS. I haven't used ReactJS before, so I'm very confused by the mixed usage of Babel, JavaScript and JSX. I try to use JSX where I can because ...
1
vote
0answers
20 views
Recursive function to copy over an object with very specific constraints
I totally suck at recursion. I have a function that works but it also looks horribly wrong. I would love to 1) Know how to write it properly 2) Know about resources to read/study so that I don't get ...
-2
votes
0answers
23 views
Java Script calculator creator [closed]
I need to create a calculator for my class. We were given the backbone of the code and told to solve certain parts. I cant get my answer code to work it says it variables are not declared and I know I ...
-1
votes
0answers
13 views
Jquery function to edit items in a to-do list [closed]
Basically, I'm working on a basic Jquery application that works like a to-do list. While I've already gotten item addition, marking, and deletion down, I'm having trouble with editing functions.
An ...
2
votes
2answers
68 views
JavaScript function to convert decimal number to binary
I was recently asked this in an interview for a front-end position and I came up with something like this which seems to work but is clunky. (Number.toString() was ...
0
votes
1answer
43 views
Angular UI Bootstrap Modal scope
I'm trying to improve my Angular skills by writing some basic applications that use a particular feature. The following application uses the UI Bootstrap modal to add users to a list, or remove them ...
1
vote
0answers
22 views
JavaScript sound manager (singleton / static object using observer pattern)
I have some JavaScript code i would like your feedback on please.
My goals:
SoundManager should be a singleton/static class that has one instance.
...
-3
votes
0answers
18 views
Merge code for text slide and text randomising when page is refreshed [closed]
Hi i'm struggling to put two codes together what will randomize the information every time page is refreshed. Also while someone is one the page, i'm wanting the change to different text.. i need this ...
0
votes
1answer
44 views
Angular front end of chat web app
I'm using the MEAN stack to make a small chat app, which will soon support braided messaging. This is my first Angular app so I am not sure how I'm doing on the front end portion in terms of keeping ...
-1
votes
0answers
28 views
2
votes
1answer
36 views
Compare data within an interval and draw rectangles accordingly
I have an interval array like below:
var interval = [[1], [1,3], [3,5], [5,7], [7,9], [9]];
I want to compare an input value say 1.5 with in the interval, and ...
4
votes
3answers
82 views
A reusable AJAX polling function
I have written a small JavaScript function which performs an AJAX request every x seconds.
I was hoping some of you could give it a look over and give me any pointers on redundant code or bad ...
4
votes
2answers
110 views
A curry function
I am new to the functional style, and I wrote a curry function to practice this new style. This curry function takes a regular function and returns the curried version of it. Currying is a technique, ...
3
votes
1answer
91 views
Function that divides money with regard to the smallest denomination
I'm writing a function divideMoney that takes the value of a sum of money and divides it according to some percentages, then rounds each division to the nearest ...
2
votes
1answer
23 views
Rendering comments in a Backbone view
I want to make show/hide logic more maintainable in my codebase.
Because they are too faraway located in separate js files, it hard for people to maintain.
The flow in my codebase is:
...
10
votes
1answer
397 views
Hangman learning AI
I have been learning AngularJS and have written my first app. It's a Hangman AI which learns words and guesses the solution based on the words it knows.
Please look over my code and provide some ...
3
votes
0answers
38 views
Displaying a Google map with multiple complex markers and unique info windows
This JavaScript file is part of a large Ruby on Rails app. Any feedback is appreciated.
Update 3.7.16: as per @Jonah's suggestion, here's a description of the code's purpose:
I've built a ...
3
votes
1answer
33 views
Renaming the iframe src attribute to facilitate lazy loading
I'm not great with javascript. I need some code to rename all iframe src attribute names to data-src, for a lazyload plugin to ...
8
votes
4answers
2k views
Randomly generate spelling mistake in string
My code will generate a spelling mistake inside of a string 50% of the time.
It will retrieve a letter from a random index in the string like, "t" and then duplicate that letter like, "tt" and store ...
3
votes
1answer
38 views
Angular JSON weather app
I'm pretty new to Angular. I wrote a weather app and need my code reviewed. I especially need help on best practices for handling edge cases on the response from the JSON endpoint.
Here's the HTML:
...
2
votes
2answers
56 views
3
votes
1answer
43 views
Script to pick random answers for a vocabulary quiz
I am making a small script, which, when run in the console on Vocabulary.com, picks one answer (the third or fourth) and clicks. Then the code checks if the answer was wrong or right and goes to the ...