Blog

Archive for the Algorithms Category


Using JavaScript Push Common Numbers from Two Arrays into a Third Array
Posted on July 31, 2015 in Algorithms, JavaScript by Matt Jennings

function commonIdsFromTwoArrays(arr1, arr2) {
// Array to push common IDs into
var commonIdsArr = [];

Read more…


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

Bubble Sort Definition

Per this video, a Bubble Sort is where an array is looped through and
Read more…

To Top ↑