This challenge is related to the JavaScript language. Note that challenges that require the answers to be in a specific language are generally discouraged.
2
votes
2answers
44 views
2D javascript table graphics
The challenge
Make a JavaScript program that can use a HTML table as a canvas, having each cell a pixel.
You can either input the position and color values in a form or by using the console.
Score ...
7
votes
3answers
189 views
Refactor variable names in JavaScript code
Your challenge today is to refactor JavaScript code. You will take three strings as input; a JavaScript string, a old variable name, and the name you want to refactor it to. For example, an input of
...
2
votes
2answers
536 views
Code Trolling Hacking [closed]
Imagine a user with the following request
Hi, I was playing a video game and my freind told me that it could be hacked by putting code in the console that affects the Game variable in the page. ...
8
votes
1answer
268 views
JavaScript load and SHA-256
This is a code golf puzzle with a real-world application. Some current browsers, if you enter a URL that looks like
data:text/html,<script>alert("hi")</script>
will execute the given ...
-1
votes
1answer
225 views
Compressing a DNA-like string [closed]
my app is multiple choice test, where for each question the response results in a 4 letter string "eg" GTAC or ATGC or CATG, etc. There are always just 24 questions. so the final result is something ...
0
votes
4answers
272 views
Find the longest word in a sentence without using regex [closed]
Have a function LongestWord(sen) take the sen parameter being passed and return the largest word in the string. If there are two or more words that are the same length, return the first word from the ...
0
votes
3answers
472 views
javascript: smallest code to convert seconds to time [closed]
Given seconds like 11728, write the smallest javascript function that returns a string like 3hrs. 15min. 28sec.
signature textTime([int] t,[bool] z,[bool] m)
t is the time like 11728 and you can ...
18
votes
11answers
1k views
Make StackOverflow Explode (bookmarklet)
Sometimes people get frustrated on the StackExchange network (specifically SO).
Your task is to create a bookmarklet that causes StackOverflow to explode/implode/destroy in some fashion. This will ...
7
votes
4answers
478 views
Display a bézier curve in the browser
The goal is to display a bézier curve in any classical browser (except maybe old IE versions, because... are they really browsers?) client side.
Rules:
You must provide one or more files (or their ...
8
votes
2answers
229 views
Write the shortest text getter/setter on an element for the DOM
Just like jQuery's $.fn.text, write one or two functions that can get and set the text on an element.
You can't use textContent or innerText, and even less innerHTML.
Plain javascript. No DOM ...
-2
votes
1answer
139 views
IPv4 “in subnet” function [closed]
Implement the following JavaScript method as short as possible:
function same_subnet(ip_a,ip_b,sn_mask)
{
}
It should get 2 IP addresses and a subnet mask. It should return true if ip_a and ip_b ...
1
vote
10answers
716 views
Convert JSON string to Key / Value Arrays
Convert JSON (key/value pairs) to a native arrays of keys & values, in your language.
var X = '{"a":"a","b":"b","c":"c","d":"d","e":"e","f":"f9","g":"g2","h":"h1"}';
The value array could be ...
2
votes
9answers
473 views
Implement String.prototype.toLowerCase()
Implement String.prototype.toLowerCase()
Description
The toLowerCase method returns the value of the string converted to lowercase. toLowerCase does not affect the value of the string itself.
...
12
votes
12answers
1k views
Javascript: Create a 10x10 array of 1s
Obviously this challenge would be trivial with separate functions and libraries, so they aren't allowed.
Your code must conform to an ECMAscript specification (any spec will do), so no ...
2
votes
3answers
1k views
Shortest code to check if a number is in a range in JavaScript
This is how I checkout to see if a number is in a range (in between two other numbers):
var a = 10,
b = 30,
x = 15,
y = 35;
x < Math.max(a,b) && x > Math.min(a,b) // -> ...
0
votes
4answers
848 views
Make an HTML page goto infinite loop?
Write a code using HTML, JavaScript, jQuery to make the page go into infinite loop.
Restrictions:
No looping or control structures of javascript and jQuery allowed. You can only use alert, events, ...
29
votes
33answers
5k views
Tips for golfing in JavaScript
What general tips do you have for golfing in JavaScript? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to JavaScript (e.g. "remove ...
2
votes
2answers
882 views
Smallest Javascript CSS Selector Engine
Create a small acceptably efficient JS CSS selector engine. Standard css 2.0 properties should be supported in Firefox 3.0+,Safari , Opera, IE7+, and extra brownie points for IE6 support.
Smallest ...
31
votes
2answers
2k views
What can you do in a 4k data URI?
Bounty is over, thephpdeveloper wins with Conway's Game of Life
The web platform today is advancing at a rapid rate. Features like CSS3 animations, transforms, drop shadows and gradients, ...
8
votes
4answers
9k views
Shortest URL regex match in JavaScript
Create the shortest regular expression that will roughly match a URL in text when run in JavaScript
Example:
"some text exampley.com".match(/your regular expression goes here/);
The regular ...