Blog

JavaScript – Euclidean Algorithm

One of the things that you often have to learn early on in school after multiplication and division is how to find the GCD (Greatest Common Divisor) of two numbers. It is possible that you know the GCD as the GCF (Greatest Common Factor) or the HCF (Higest Common Factor). Read more…

By Chris West, ago
Blog

POW Answer – Explain That SQL #1

To answer last week’s POW, the purpose of the SQL was to generate a random string of letters and numbers. I actually wrote two different JavaScript function that can produce the same results. The following is the slightly more straight-forward solution: The next version is a bit harder to follow Read more…

By Chris West, ago
Blog

JavaScript – Binary Search

The following is an implementation of a binary search for arrays which gives you the ability to do fuzzy matches (default), exact matches, or specify your own comparison function: I used the following to test the normal execution of this binary function:

By Chris West, ago
JavaScript

POW Answer – Unnamed Function #1

The answer to last week’s Problem of the Week is that the following definitions represent the factorial of the given non-negative integer: Mathematical Definition Function Definition Condition unnamed(n) = 1 if n = 0 n × unnamed(n – 1) if n > 0 JavaScript Definition Although it may have been Read more…

By Chris West, ago
Blog

Deep Copy of Arrays

With jPaq and many other JavaScript libraries, it is very easy to do a shallow copy of an array. On the other hand, it isn’t as easy to do a deep copy of arrays. For this reason, I plan on replacing the Array.prototype.clone() function with the following: The above code Read more…

By Chris West, ago