jPaq Examples

April 6th, 2011 @ 6:30:51

Counting Squares On A Checker Board

How many squares are there on a checker board?  Most people would say there are only 64 squares, but others would say what about the board itself?  Isn't that a massive square?  How about the squares that are half the size of the entire board?  …
April 4th, 2011 @ 9:49:38


At times, you may want to call a function a number of times, but you may notice that the first few arguments are always the same. This is where the curry() function comes in handy. Let's use a simple example.  Let's say that we have a function…
April 4th, 2011 @ 6:29:13

Finding & Replacing with Wildcards

The following shows you how to search strings by using wildcards and even how to replace what you find: alert("Where in the world is Carmen Sandiego?".findPattern("C*n")); alert("Christopher West".replacePattern("() ()", "p", "$2, $1")); alert("2 to the 64th is 18446744073709551616.".findPattern("#{3,}", "ol"));
April 4th, 2011 @ 6:23:57

Foreground vs. Background

I think one of the biggest complaints of users and web designers is the fact that many times people use background colors that are too close to the color of the text. In order to avoid this, there is a Color.prototype.getSafeColor() function of the Color class that indicates…
March 30th, 2011 @ 12:30:50

Padding Numbers

At times you just need to add padding to strings for presentation's sake.  For instance, have you ever needed to make sure that each number in an array had a specific number of digits?  The following example will generate 10 random numbers and then make sure they…
More News:  12