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
41 views
Integer to English challenge
I have a challenge, which is to create a JavaScript function that turns a given number into the string representation. For example:
console.log(inToEnglish(15)) ...
0
votes
0answers
11 views
Diff Two Arrays - return the symmetric difference of the two arrays
This is my challenge using JavaScript -> Compare two arrays and return a new array with any items only found in one of the two given arrays, but not both. In other words, return the symmetric ...
0
votes
0answers
7 views
iframe play & thumbnail function
This is quite a simple function, but I just wanted to opinions on it. E.g is this the correct way to run a function and check if the element exists or not?
...
0
votes
0answers
9 views
4
votes
0answers
24 views
Recorder for keyboard and mouse events
I'm building an event recorder. So far the code looks clean but I feel I'm missing something that can make this code even better.
Is composition a better solution? If yes, how can I do it properly in ...
3
votes
1answer
54 views
Sudoku solver in JavaScript
I decided to learn JavaScript and what better way than wrestling with a Sudoku solver. I'm guessing there are (many?) optimizations that I missed. I'm thinking of adding a generator also, but this for ...
0
votes
0answers
39 views
Wikipedia search using the JSON API
I ask to you. What I could do better in my code or logic?
This my example on Codepen -> Wikipedia Search
...
0
votes
0answers
10 views
Running actions on button click
If the user clicks a button, I need to run the following actions:
Show and hide div
Add and remove attributes
Add and remove CSS class
We archive the same but I'm not sure this is the correct ...
-1
votes
0answers
9 views
jQuery - Add/remove class when height changes [on hold]
I reached an issue when trying to add Class if div's height has changed (it's a responsive website project).
My Javascript:
...
1
vote
1answer
24 views
Secret Santa random pair allocator
Please review my Secret Santa random pair allocator written in JavaScript. Random pairs will be generated every time you run the code.
Input data is hardcoded for now (line # ...
0
votes
1answer
21 views
Balanced parenthesis string checker
Please review my balanced parenthesis string checker code below.
I would love to know how to improve my algorithm and if you have any other feedback.
...
1
vote
0answers
20 views
Basic animation in Typescript
I decided to play around with doing my own super-basic animation. For a previous Javascript project, I needed the ability to flash an element. The code below is the result of me attempting to ...
-1
votes
0answers
15 views
Return a list of data made from an Ajax/HTTP in the order they were called [migrated]
Is there a way to get your data back in the order in which you called your AJAX requests, without using promises, also no synchronous code or jQuery, but simply pure javascript?
I'm quite familiar ...
-4
votes
0answers
14 views
how to connect liaison API lapi.ocx with php page [on hold]
I have sample code in VB but I don't know how to connect it to a PHP page, send commands, receive the result from sita servers, analyze the answers and show the result.
Here is the sample code in VB:
...
-1
votes
0answers
14 views
How can I finish building out a PJAX “driver”? [on hold]
I'm not much of a javascript developer, and am building out a PJAX "driver" that requires 0 interaction, and easy manipulation of a website, so how would I improve this function, and make it work ...
4
votes
2answers
52 views
Fancy checkbox for web pages
I just finished creating a fancy checkbox and am hoping for some tips to help improve my code, as I am still learning.
...
-2
votes
0answers
10 views
Sorting out array of parent child relations where two children share a parent from an array and display it using div [on hold]
I have the following data which gets served from a neo4j query, The data that gets sent back is in the format
...
2
votes
2answers
66 views
sum, range and rangeSum functions
Forgive me if this is too simple, but I'm a beginner trying to learn and understand. I came across an exercise to create these three basic functions, and this is what I came up with.
Any glaring ...
2
votes
1answer
30 views
Regrouping JSON object
I wrote a JavaScript source which regrouping by new key i.e. following JSON to the other:
...
2
votes
0answers
24 views
Node.JS HTTP shortcut wrapper
The Node.JS HTTP and HTTPS modules only provide .get shortcut function, unlike AngularJS's $http which provides them all. I went ...
1
vote
0answers
22 views
NodeJS Configuration Exporter
I have created a NodeJS script that I will be using to export front-end configuration details from my Zabbix installation, which will then be sent to my secondary (backup) Zabbix installation to keep ...
0
votes
0answers
10 views
Manipulate original DOM in React.js
As an introduction, I would like to have my inputs validated with the built-in validation HTML5 attributes, e.g. use pattern for text input. So this is my sample code that implements that.
Is it ...
0
votes
0answers
10 views
Nested values copies from one object to another
Here is a nodejs code that copies values from one object (submitted from a firm) to a model object.
Model:
...
0
votes
0answers
23 views
jQuery toggle buttons to show matching content in sliding panel
I have a sliding panel that I want to show content in. The content that I want to appear depends on the button that triggers the sliding panel. My project is growing rapidly and I would like to ...
-2
votes
1answer
33 views
Dropdown menus with toggling ⬇︎⬆︎ icons
I have some html and js codes. I can't understand how can I dry up this codes. I am using bootstrap-3 and jquery-1.11.0. on my js code I have some dropdowns. In dropdown I used a icon. When the ...
0
votes
0answers
40 views
Unit tests for an Express middleware function that does basic authentication
I have written an Express middleware function called authenticateRequest that looks at the Authorization header of an incoming ...
10
votes
1answer
129 views
+50
Make a summary from a larger text-file
This code makes summaries from larger texts.
I have searched around for an algorithm and found the following:
Associate words with their grammatical counterparts. (e.g. "city"
and "cities")
...
5
votes
1answer
43 views
Adding a replica of some DOM elements on click
I have the following code which inserts a new element of the same type over and over again to the parent element. I am new to JavaScript so was wondering if there was a better way of doing this. I ...
-2
votes
0answers
11 views
Canvas makes website unresponsive, doesn't draw anything and freezes up [on hold]
Those are the symptoms. Init() is called from onload="init()" in the <body>. the image is a 40 x 40 image of a grid, that ...
1
vote
0answers
18 views
Make jquery pagination more efficient
I am trying to create pagination with pure PHP and jquery. I have done this and it works exactly how I want it to work. Essentially I get all products from my database using PHP.
I then populate the ...
1
vote
1answer
47 views
Focus next element on keypress
It's been a year or two since I last dabbled in jQuery and have attempted to write a simple "on key press move to the next element" script. However my first attempt has a lot a repetition. I just ...
4
votes
2answers
49 views
Calculate the difference between current date and age from personal ID
The goal is to show message for users that are less 25 years old. The personal ID consists of 081010333333, where 08year, 10month, 10date. I made code and it's very messy. So the question is: how to ...
-3
votes
0answers
19 views
0
votes
0answers
22 views
Angular.JS directive to show 225 items in a grid
I'm a newbie in angularjs who has been tasked with optimizing this code.
The following directive lists information in a table. The table uses pagination with 25 items per page and 11 items that can ...
2
votes
0answers
9 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
...
3
votes
1answer
38 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
29 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
41 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
22 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
22 views
desparate TicTacToe please [closed]
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?
...
7
votes
0answers
65 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
41 views
-3
votes
0answers
24 views
Replacement for if-elseif block in javascript [closed]
I want to simplify this chain of if and else if statements. How can I achieve it?
...
2
votes
0answers
54 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
1answer
63 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
27 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
24 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
46 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
21 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 ...