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
vote
0answers
13 views
Dijkstra's algorithm in JavaScript
I couldn't find any other versions of Dijkstra's in JavaScript online other than one that used a priority queue and needed a start vertex and end vertex as arguments.
Here is my attempt at coding ...
0
votes
0answers
8 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
1answer
28 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
17 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 ...
1
vote
0answers
35 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
34 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 ...
0
votes
0answers
13 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
16 views
Java Script calculator creator [on hold]
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
12 views
Jquery function to edit items in a to-do list [on hold]
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
54 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
17 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
18 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 [on hold]
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
33 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
24 views
2
votes
1answer
34 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
73 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
102 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
76 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
374 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
29 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.
...
2
votes
1answer
32 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
32 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
41 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 ...
3
votes
3answers
33 views
Set same color as prev row if data matches otherwise different color
I have a requirement in which I need to set color of two or more rows of a table same if they have same value in cell one and I have to maintain this alternatively i.e. no 3 or 4 rows should have the ...
2
votes
2answers
58 views
AngularJS shopping cart using local storage
Two weeks ago I started writing some Javascript and AngularJS code for a customer. As a proud newby I must also be aware of the dangers on the big bad Internet. In particular vulnerabilities such as ...
0
votes
1answer
38 views
Accordion navigation
For an intranet site with large description-texts I made these website with an accordion navigation.
...
1
vote
1answer
50 views
Web Page Inspector
I wrote a small JavaFX Application to inspect Javascript within HTML pages. It loads and browses sites, shows the HTML source, shows an overview of the text of a page, provides a simple Javascript ...
2
votes
1answer
38 views
My user registration factory for AngularJS + Firebase app
The goal for this code is to provide a semi-secure and privileged method of user registration via a secret code that is stored as a key in the Firebase database.
Subscribers to a mailing list were ...
1
vote
1answer
43 views
Creating a RegExp in JavaScript from user input
My goal is to accept user input regex in the following forms
/regex|here/i
/regex|here/
...
0
votes
1answer
44 views
JavaScript Modal
As part of my effort to learn JavaScript, I have started developing a small library for creating DOM widgets like modals, tooltips and so on from scratch (nothing but plain vanilla JS allowed in other ...
3
votes
1answer
87 views
Clickable and automatic image slider
I created a slider that fades images automatically but you can also click to see the next or previous image. It already works how it should. But I think my code is really heavy. I am not experienced ...
-1
votes
1answer
37 views
Two timeout methods
I found there are two methods to code an if-else statement with a timeout function. Two of these scripts work fine, but which ...
1
vote
1answer
24 views
Polling hash change
I've discovered that Google Chrome on iOS doesn't fire the hashchange event when the back / forward buttons are pressed.
Reference:
...
0
votes
0answers
20 views
Draggable and resizable buttons
I made draggable and resizable buttons using Vue.js (a simplified version of Angular.js) and Interact.js (a library like d3 but focused on DOM interaction).
This is the HTML. The grid and plane div ...
1
vote
2answers
51 views
Regex to match strings safely
The following regex is meant to improve stringmatching by sanitizing the user -defined commandPrefix and checking for whitespace and line-endings after the ...
3
votes
1answer
70 views
Fading content for each TD
I have an HTML table and I use jQuery to fade some content for each TD:
Demo
My code works great, but I want to know if my solution can be better.
...
-5
votes
0answers
21 views
I am learning Java Script ( “While”) [closed]
var count = 0;
var loop = function(){
while(count < 3; count++ ){
console.log("I am looping");
}`enter code here`
};
loop();
I need to write ...
2
votes
1answer
36 views
Angular/bootstrap radio button directive
I found creating radio buttons in my application a bit of a hassle in terms of having to configure the HTML to do what I wanted when the user clicks/unclicks the items etc.
I figured reducing it to a ...
1
vote
2answers
61 views
Keyboard handler to move a shape in response to arrow keys
I finished Codeacademy and I'm looking to practice and get better at JavaScript. Is this coded correctly or should I have made a function for it somehow? The purpose of this code is to move a square ...
1
vote
1answer
45 views
Popup on footer to make an email list
I'm creating a simple popup to be shown on footer of pages to make a email list.
I would like you to give a look at the code below if possible .. and would appreciate some suggestions in respect of ...
-1
votes
0answers
10 views
Jquery Change() method is repeating on click(x + 2) [closed]
I have write some code in Js For my plugin.. During writing a script i followed by strange problem that Jquery method change() continue repeating x+2 times.
Means ...
1
vote
3answers
33 views
Navigation script and template
Overview:
I'm using the following page template and scripts for navigation. I use a single page that loads menus and context content, and then use ajax or GET variable to load main-div's content, by ...
-4
votes
0answers
23 views
Javascript program to find grade of three tests [closed]
I have been trying to learn Javascript, and I am currently working on a program that reads in three test scores and returns either an "A", "B", "C", ect. I am able to find the total of the test ...
2
votes
1answer
31 views
Slider control constructor
I've made myself a JavaScript slider constructor. You can create new sliders and tell it what elements it should refer to.
...
4
votes
1answer
60 views
Last dot Standing Puzzle Game
The game is a puzzle game made up of a grid of cells represented by html divs. Gameplay is as follows:
On starting a new game, the number of rows and columns is selected from a form.
The grid is ...
1
vote
1answer
44 views