Questions tagged [javascript]

ECMAScript or ES (commonly referred to as JavaScript) is primarily used for scripting web-pages but also has several embedded forms as stand-alone interpreters or JIT compilers. Use this tag for questions regarding all versions of ES up to the current ES8 and its dialects / implementations: JavaScript, JScript, etc., excluding ActionScript.

Filter by
Sorted by
Tagged with
3
votes
4answers
2k views

JavaScript Random Color Generator

I made a page to generate a random color with JavaScript and set that color to the background of the page. ...
3
votes
1answer
3k views

Checking if variable is defined before accessing its properties [closed]

I didn't write this but I noticed it in our codebase at work. ...
3
votes
1answer
64 views

Simple JavaScript Module “Loader”

I have written a simple JS module "loader" (loader is in quotes because it doesn't actually load the files) that is designed to resolve simple dependencies between modules. It is heavily inspired by ...
3
votes
2answers
989 views

Simplifying Counter of Checked Checkboxes

Is the following code a proper solution to my problem? I have a feeling it can be simplified quite a bit. If one of the first four checkboxes is checked the sum is 1; if two 1.5; if three 2; if ...
3
votes
1answer
99 views

Rock, Paper, Scissors, and the Revealing Module Pattern

After reviewing this approach: Rock-Paper-Scissors with the revealing module pattern I decided to write an alternative where the Revealing Module Pattern is used for the UI, model, and controller. I ...
3
votes
1answer
200 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 ...
3
votes
3answers
121 views

fizzbu| - Fizzbuzz with dynamic height

Here is a variation on a theme: fizzbuzz. After providing this answer recently, I decided to practice some VueJS skills with outputting the values and conditionally applying styles based on the value. ...
3
votes
1answer
75 views

Can phrase be made from whole words in another string?

I am working to solve this HackerRank puzzle: Hash Tables: Ransom Note The premise is that if I am given a string like this: give one grand today I can find a match for each of the words in the ...
3
votes
1answer
420 views

Wrote javascript version of error monad / monadplus, did I obey monad laws correctly?

Just looking for some critiques hopefully from haskellers of how I might be breaking monad laws or just monadding all wrong. My or is something like the ...
2
votes
2answers
97 views

Range Sum Challenge

I was solving this challenge on the leetcode site. And my runtime is horrible, it beats only 4% of the other solutions. How can I make this better? ...
2
votes
2answers
111 views

jQuery Tab Scroller

I've never had anyone review my code. I actually found full-time work as a web developer and in the interest of ensuring that I'm always improving, I'd like to see if I'm doing things the proper way. ...
2
votes
1answer
57 views

Add colour tags on click

I have implemented some extra functionality for the tag-it JavaScript plugin, where I need an option where availableTags are displayed in one box, and the user can ...
2
votes
1answer
6k views

Milliseconds to Time string & Time string to Milliseconds

Fast Time conversion I'm trying to write a very fast time-to-string and string-to-time function. I noticed that on low CPU mobile devices this function has, even if minimal, impact on the ...
2
votes
2answers
547 views

Infinite scroll for currency list

I made infinite scroll for a currency (in the code below: valute) list. The currency list is fetched via an AJAX-request from a remote server. After it starts the script displays 10 records. After the ...
2
votes
2answers
444 views

Genetic Drift simulator

Genetic drift — along with natural selection, mutation, and migration — is one of the basic mechanisms of evolution. In each generation, some individuals may, just by chance, leave behind a few ...
2
votes
1answer
238 views

Truncate text to some number of words when clicked

I am currently using the code below to truncate text: ...
2
votes
0answers
768 views

Simple clicker game

I have started my clicker game using angular.js about week ago. I have finished current functionality first night, but still have feeling of misunderstanding some basic approaches. This is sources ...
2
votes
1answer
7k views

jQuery function to link nested checkboxes

...
2
votes
0answers
21 views

Fast algorithms in Javascript for shortest path queries in directed unweighted graphs - follow-up

(See the previous iteration.) Now I have reworked my pathfinder program, and I ended up with this: ...
1
vote
1answer
2k views

jQuery Widget - Progress Tracker

This is a follow up on JS Progress Bar Widget I've rewritten it as a jQuery Widget Factory widget, attempting to follow that standard as much possible and fixing the various problems pointed out in ...
1
vote
1answer
121 views

Upload and drag the image inside a mask image

I am allowing users to upload and drag images with this code. Give me a review of this. Codepen ...
1
vote
2answers
490 views

From an given array of numbers remove duplicate values

I was asked an question for writing a program where the input will be array of numbers; the output of the program will be array of numbers without duplicates. I coded in javaScript which runs on ...
1
vote
1answer
691 views

Parallax animation running well on Chrome but slow on Safari

This is the continuation of a previous question I posted here. I've improved (at least I think so) the initial script from the previous question, now storing the data in an array, it runs slightly ...
0
votes
1answer
78 views

Combining hover functions

I have many <spans>s which need to group to change opacity after hover. All of them need to have unique IDs. Is there a way to combine all these hover ...
0
votes
1answer
2k views

Angular version of FitText

This project has evolved a lot since I started learning Angular. I'm pretty happy with it now, and I'm wondering if there's anything I can improve upon, or have forgotten at this point... HTML ...
0
votes
2answers
198 views

Largest prime factor function

I have written a function which finds the largest prime factor of some number. This function works but the problem is that it is too slow. For instance, when I enter 600851475143 as a parameter, the ...
33
votes
4answers
1k views

Memory with a twist

Description This is the good old game Memory with a twist: Every time you pick a wrong pair, the two tiles you chose will switch their location. So sometimes you might think that a tile is at one ...
13
votes
1answer
281 views

Naming numbers in American English

This seems like a popular topic lately, so I took a crack at it. Related questions are Number to Words and Converting a number to the text representation. I used this article as a guideline. The ...
11
votes
3answers
4k views

Ultimate Tic-Tac-Toe Challenge

This is my attempt at the Ultimate Tic-Tac-Toe code challenge. It uses jQuery to build out the game grid and find the states of all the "buttons" (actually ...
11
votes
4answers
1k views

Arabic to Greek numeral converter, 1 - 10

One of the things that's straight-forward in JavaScript is Unicode support. If you want to return ϝ (lowercase digamma, not a simple ...
11
votes
1answer
88 views

Improved Sound Control System

After a bit of work, I've changed my code a lot from the previous question: I was recommended by George Mauer and schism to make a better structural design, so hopefully this new build is a bit ...
11
votes
1answer
528 views

node.js Passport Wrapper 2

First attempt was done here: My second attempt (now using jslint to make sure the spacing is correct and have incorporate the majority of the feedback from previous attempt). ...
11
votes
1answer
146 views

Wandering water ways

An entry for the August 2016 Community Challenge I slightly modified the input and output to suit the snippet tool, and also because I really like the mapped output with the basins. I have been ...
10
votes
1answer
136 views

Script to convert Shift + Spacebar into four spaces on SE

I've posted this feature request and would like to improve the code involved to handle a few "bugs" (not that it's necessary to provide such code, just for my own practice), but I doubt I'm doing it ...
10
votes
2answers
168 views

Member list reveals member information on click (#1)

What I'm doing? I'm creating a member-list where initially only the names are visible. Clicking the names reveals the member information. This is done with jQuery by adding/removing classes. I left ...
10
votes
4answers
4k views

Codility binary gap solution using regex

Below is the code I implemented to solve the binary gap problem: Find longest sequence of zeros, bounded by ones, in binary representation of an integer. However, it seems to be different from ...
10
votes
2answers
75 views

Badge Oneboxer for Chat.SE

This script makes it possible for badges to onebox in Chat. The install requires Tamper/GreaseMonkey. Click here to install, and it's on GitHub and StackApps! ...
10
votes
2answers
2k views

Optimize/Refactor Javascript Unique Array function

This is one idea of implementation: ...
9
votes
1answer
225 views

Cardshifter login page using vanilla JavaScript

I'm working on rewriting the Cardshifter HTML Client with vanilla JavaScript, the original HTML Client is written with Angular but I really wanted to stay away from anything npm and just go back to ...
8
votes
3answers
2k views

jQuery Upvote, a simple Stack Exchange style voting plugin

I'm not very good at JavaScript, so it would be great if somebody could review my jQuery Upvote plugin, and point out mistakes, bad practices, or anything suspicious. The repository is on GitHub. ...
8
votes
1answer
461 views

SVG mosaic creator

Although my code works as expected, there are a few gotchas. A single row is not filled at once; instead, I can see partially filled rows during the rendering process(Fixed in the updated code below.)...
8
votes
2answers
725 views

The Scripted FizzBuzz Kata

I run a coding dojo at work. for one session I'm to showing that you can use a kata to get into a new language. I'm using the FizzBuzz Kata to show JavaScript (and F#) because it is short. The ...
8
votes
1answer
289 views

Karma Sutra game

I have created a simple Javascript game and want some second opinions on the code. How can it be done more efficiently for example? Please see the code below, plus a link to a live working version on ...
8
votes
1answer
128 views

Chart of Percentage questions Answered

Every day, Duga reports the number of unanswered questions and percentage of answered questions (after she calls the API endpoint /info) in The 2nd Monitor (so we ...
8
votes
1answer
287 views

Pretty printing degrees input to radians

I'm mostly concerned about edge cases, although I think I dealt with them all. Improvements on code quality would also be much appreciated. ...
7
votes
2answers
97 views

Simpler number theory game

After receiving some awesome feedback in my first post yesterday, I was able to grasp the "building block" method of creating javascript in chunks and putting them together to create coherent/...
7
votes
1answer
192 views

Self-playing Baseball game — An es6 update

A long long time ago I asked this question which has since garnered about one thousand views. Now for something new. The demo for what I have is located here. I am generally happy with what I have ...
7
votes
3answers
229 views

Airflow calculator

I have started to learn JavaScript over the last few weeks. I have gone through most of the Head First JavaScript Programming book and it has been fantastic. I highly recommend it! Anyways, I found a ...
7
votes
1answer
60 views

Catch-style unit testing in JavaScript (phase 1)

I decided to port my favorite unit testing framework, Catch, to JavaScript. So far I'm focusing on test cases and sections. I'll add assertions in phase 2, and output in phase 3. The goal for this ...
7
votes
3answers
1k views

HackerRank “Ransom Note” challenge

I have solved the Ransom Note challenge on HackerRank using JavaScript / ECMAScript 6. The challenge goes like this: A kidnapper wrote a ransom note but is worried it will be traced back to him. ...