Blog

Archive for the JavaScript Category


JavaScript Function to Find the Longest Common Prefix
Posted on July 20, 2015 in Algorithms, JavaScript by Matt Jennings

In a JavaScript array, find the longest common prefix of all array elements.

function longestCommonPrefix(arr){
// sort() method …

Read more


JavaScript Merge Function that Mergers Two Arrays Already Sorted from Lowest to Highest Numbers
Posted on July 15, 2015 in Algorithms, JavaScript by Matt Jennings

// Function merges 2 arrays that are already sort from
// Lowest to highest numbers
function mergeSortedArrays(arr1, arr2) {

Read more


JavaScript Insertion Sort Algorithm
Posted on July 14, 2015 in Algorithms, JavaScript by Matt Jennings

See this Wikipedia entry for the insertion sort algorithm. This animated GIF from that entry explains more …

Read more


JavaScript Bubble Sort Functions Using a Do/While Loop and Nested For Loops
Posted on July 13, 2015 in Algorithms, JavaScript by Matt Jennings

Per this video, a Bubble Sort is where an array is looped through and the largest …

Read more


Using OOP JavaScript and jQuery to Shuffle a Deck of Cards, Deal a First Card, Deal a Random Card, and use this
Posted on July 9, 2015 in JavaScript, jQuery by Matt Jennings

Some of the code snippets below are from my deck of cards JavaScript game that uses object constructors, …

Read more