All Questions
473 questions
5
votes
1
answer
3k
views
Displaying JavaScript object's structure on page with HTML
I wanted to reproduce the type of navigation system found in the console of Firefox and Chrome: you can explore an object's properties by unfolding boxes:
So I'm searching to:
display all of the ...
5
votes
2
answers
663
views
How to optimize bitwise get/set/clear of ranges of bits on 8-bit integers in JavaScript?
I have been working for a few days on writing get, set, and clear bitwise functions in ...
5
votes
1
answer
4k
views
Interview Coding Test: Transaction Processing: Get balance by category in given period
I recently gave a coding test for a job which failed. It had two problems and one of them is shared in this question along with my solution.
Problem: Get balance of all transactions in a given ...
5
votes
1
answer
291
views
Container with most water
The task
is taken from leetcode
Given n non-negative integers a1, a2, ..., an , where each represents
a point at coordinate (i, ai). n vertical lines are drawn such that
the two endpoints of ...
5
votes
1
answer
3k
views
Parking Lot Management System in JavaScript
Hypothesis
There is a paid parking lot, with the following rates: $1 for the first hour and $0.5 for every subsequent hour. The parking capacity is of 10 spaces.
Required
Make an activity management ...
5
votes
1
answer
185
views
Express.js blogging application
I have put together a blogging application with Express, EJS and MongoDB.
There is a public, front-end part and a dashboard. In index.js I have:
...
5
votes
1
answer
411
views
Recursive JavaScript permutations function
I have a recursive function that calculates the permutations of a given list/array list. Although a similar implementation works great in Python, this JavaScript ...
5
votes
1
answer
110
views
Advent Of Code 2017 Day 4 (part 2) in Functional Programming (FP)
I wanted to practice functional programming (FP) without using any library but using vanilla JavaScript only. So I took a problem from Advent of Code (the 2nd part of Day 4)
You can only access the ...
5
votes
3
answers
3k
views
Reverse Integer
The task
is taken from leetcode
Given a 32-bit signed integer, reverse digits of an integer.
Example 1:
Input: 123
Output: 321
Example 2:
...
5
votes
2
answers
2k
views
BlackJack in Javascript
I have completed my initial version of BlackJack with Javascript and some JQuery. Any thoughts of this version? I can't seem still to implement timer successfully as I have commented out. After ...
5
votes
1
answer
314
views
Find the starting indices of all occurrences of the pattern in the string - KMP algorithm follow-up
The task
was initially solved here, but was too buggy:
Given a string and a pattern, find the starting indices of all
occurrences of the pattern in the string. For example, given the
string "...
5
votes
2
answers
4k
views
Safe navigating function for nested object properties
I've made a function to safely traverse deep objects.
...
5
votes
1
answer
8k
views
Wrapper for jquery ajax to ensure redirects occur on clientside
Recently I had the need to make some ajax calls within a MVC 3.0 with Razor and jQuery application. After a bit of trial and error and refactoring it was discovered that a number of different needs ...
5
votes
1
answer
309
views
Rock-Paper-Scissors with the revealing module pattern
In my ongoing effort in learning advanced JavaScript I tried to develop the traditional rock paper scissors game by using the famous revealing module pattern. I'm not comfortable yet with what has to ...
5
votes
1
answer
433
views
Reading the contents of an XPI file
I wrote this code to list contents of an XPI file and then read the contents in it.
I was thinking of these areas of improvement:
I put the zr.open in the ...
5
votes
1
answer
540
views
Personal project for managing my bookmarks
I am working on a personal project for managing my bookmarks, which is basically a web page to manage my bookmarks by categories. Managing here means everything - adding, viewing, updating, searching ...
5
votes
2
answers
1k
views
Handling multiple click events of sliding divs
You are first confronted by three links. Each link triggers divs to slide out.
The divs slide out and up to appear as if unfolding. The slide back in reverse when any other link on the page is ...
5
votes
2
answers
177
views
Updating Grid on Webpage
Task:
Draw a grid with a given number of rows and columns. Each cell can be
any color. The same grid should also be updated at a predetermined
time interval. The grid should cover the entire ...
5
votes
1
answer
1k
views
Parallax animation, running well on Chrome but slow on Safari
I have the following script to create a parallax effect on the page using request animation frame, it runs well on Chrome, but on Safari is lagging, I think because I run too many calculations on each ...
5
votes
2
answers
1k
views
Tiny JavaScript live filter
I'm looking for feedback on this live-filter I wrote in JavaScript. You can test it using the included snippet.
...
5
votes
1
answer
356
views
Two keyboard handlers for a video game character
The code below is equivalent. I can see pros and cons for both versions. Which is better: the short, clever way, or the long, ctrl+c way?
Short version:
...
5
votes
1
answer
285
views
Simple JavaScript (sub) class [properties, getters, methods]
The more I consider object oriented JavaScript the more I am confused. There are so many different ways and concepts and I simply do not know any longer what fits best for my purposes.
I like the ...
5
votes
3
answers
9k
views
Prefix and suffix detection algorithm
I have written an algorithm intended to find prefixes and suffixes in arrays of strings.
I would like to get opinions/suggestions/reviews on the code I wrote (specially cases in which my code would ...
5
votes
1
answer
248
views
Transforming jQuery form code into clean code
The following JS code handles when the form is submitted and some little extra stuff.
I'd like to have it reviewed on the following aspects:
Readability
Efficiency
Usability
OOP
It works exactly as ...
5
votes
1
answer
442
views
node.js Passport Wrapper 3
First attempt was done here
Second attempt was done here
Huge comment at top
...
5
votes
2
answers
1k
views
Implementing range() in JavaScript
For fun, I implemented a version of Python's range function in JavaScript. I found that underscore.js implements it as well, but with notable differences. I'm ...
5
votes
1
answer
2k
views
Linear algebra, reduced row echelon form
The code that I am sharing here for you to review today, is a segment of a JavaScript library that I am going to write as time goes by for fun. It is only the two functions in the following code:
<...
5
votes
1
answer
2k
views
JS Progress Bar Widget
Demo of the widget: http://jsfiddle.net/slicedtoad/Lywvbsf4/
It's a progress bar that shows a list of steps and which one is being completed as well as allowing previous steps to be revisited.
It ...
4
votes
1
answer
106
views
Advent Of Code 2017 Day 4 (part 1) in Functional Programming (FP)
I wanted to practice functional programming (fp) without using any library but using vanilla JS only. So I took a problem from Advent of Code (the 1st part of Day 4):
A new system policy has been ...
4
votes
1
answer
179
views
Mapping file data to environment variables
This is a follow-on to my previous question: Enforcing set environment variables
While learning more about JavaScript, node, and the bluemix environment, I have been using the loading of process ...
4
votes
4
answers
21k
views
Defining constants in JavaScript
I am aware JavaScript does not have the concept of constant variables, which in traditional languages, you would usually define as being static/class related since there's no point in having them ...
4
votes
2
answers
12k
views
A better solution for nested maps
I'm trying to build a nav, but the way I currently have the data setup I'm having to map within a map with a map to get all of my data out - I have a feeling that this is a poor way of doing something ...
4
votes
1
answer
418
views
Simple morphing button concept
I have been making a jQuery morphing button type thing.
jsFiddle
...
4
votes
1
answer
217
views
Color slider for different gradients
I am creating a color slider, and I'm trying to make the slider's background-color a dynamic gradient. I've successfully did it, but I feel this can be done in a ...
4
votes
4
answers
315
views
Helper function to format-output any type of variable
This question has already got some reviews, so I could partially improve my code: please look at my self-answer below, which also contains comments about the review.
I'm frequently interested to ...
4
votes
1
answer
167
views
Improving a filter array function, to match elements and conditions
I have to do some check/match elements with conditions.
A have a list of conditions, each with a specific ID.
I've put for each of my elements an array with the ids of their respective affirmative ...
4
votes
2
answers
181
views
"toast" mini-library
I refactored the code for a library that creates toasts. I have borrowed most of my naming conventions (and constant naming conventions in specific) as well as the design pattern from Bootstrap's ...
4
votes
2
answers
7k
views
Simplifying an AngularJs directive that counts the number of characters entered in a textarea
I am trying to implement an AngularJS directive that would count the number of characters entered into a textarea and display it to the user.
Note: it will actually become much more complex later on ...
4
votes
1
answer
73
views
Style-changing handler for an HTML drop-down box
How can I maybe do some loop that will compress the amount of JavaScript/jQuery I need to use. I have a function s3episodesChange() linked to a ...
4
votes
1
answer
3k
views
Circle - Line segment collision
I wrote an implementation of circle - line segment collision detection algorithm. Here is quick demonstration how it works:
And here is my implementation in Javascript using HTML canvas:
index.html
...
4
votes
3
answers
2k
views
Quadratic equation solver in JavaScript
The task is to implement a solveEquation function, which solves the Quadratic equation. Each equality has exact 2 integer solutions. Return those numbers as an ...
4
votes
1
answer
166
views
Audio frequency trainer / tester using Web Audio API
I'm making an audio frequency trainer as a learning exercise. It could be useful for audio technicians who need to recognize audio frequencies (eg. when ringing out feedback during a live concert or ...
4
votes
1
answer
216
views
Displaying Media with HTML and JavaScript
I have a personal website that I use to share videos and images with friends. Below is a media generator using JavaScript and HTML. Its main purpose is to display one image at a time at the click of a ...
4
votes
1
answer
512
views
Tip Calculator in pure JS
A simple tip calculator that asks for the total bill amount, service quality (used to determine what percentage of the total cost will be tipped), and how many people are sharing the bill (used to ...
4
votes
2
answers
1k
views
Check whether string of braces, brackets, and parentheses is balanced
The Task
is taken from codewars:
Write a function that takes a string of braces, and determines if the
order of the braces is valid. It should return true if ...
4
votes
1
answer
53
views
Catch-style unit testing in JavaScript (phase 2)
Continued from phase 1; please read it first for background.
Overview
This phase focuses on assertions. Here's where things get ugly. Catch uses macro expansions to decompose assertion expressions. ...
4
votes
1
answer
233
views
Doubly Linked List with forward and reverse iterators (javascript)
A doubly linked list contains elements that include pointers to the previous and next element along with a value. Being able to search and iterate through the list in both directions is an important ...
4
votes
1
answer
819
views
Read files from a directory using Promises
Using javascript functions and the old way of doing things I wrote a piece of code to copy the first file in a directory to a file Test.
...
4
votes
3
answers
6k
views
JavaScript - prototype, getters, setters, functions
I'm just getting to know the whole prototype world, and now I'm trying to do in JS what is normally done in OO languages, namely classes and DAO classes.
I'd be grateful for any comments on whether ...
4
votes
2
answers
1k
views
implement the merge functionality for 2048 with JavaScript
I am trying to implement the game 2048 using JavaScript. I am using a two-dimensional array to represent the board. For each row, it is represented using an array of integers.
Here I am focused on ...