Blog

Archive for the Algorithms Category


JavaScript Function(s) that Deal with Palindromes
Posted on June 17, 2015 in Algorithms, JavaScript by Matt Jennings

// Check if a string is a palindrome
function palindromeCheck(palindrome) {
var arr = palindrome.split(“”);

var reverseArr = arr.reverse();

var reverseArrJoin = reverseArr.join(“”);

if(palindrome == …

Read more


In JavaScript Fibonacci Number Recursive Function Examples
Posted on June 16, 2015 in Algorithms, JavaScript by Matt Jennings

Basic Fibonacci Number examples with 4 as an input is below:

/*
Recursive function to return a single Fibonacci Number
*/

function …

Read more


In JavaScript Create a Function that Takes a Number to Return a Factorial
Posted on June 15, 2015 in Algorithms, JavaScript by Matt Jennings

function factorialInput(num) {
var factorial = 1;
for(var i = num; i > 0; i–) {

Read more


In JavaScript, a Function to Add Numbers from 1 to 4 Million Using the Modulus Operator
Posted on June 11, 2015 in Algorithms, JavaScript by Matt Jennings

/*
Add numbers 1 through 4 million inclusive that are
divisible by 3 or 5 but NOT divisible by 3 AND 5
*/
function …

Read more


In JavaScript Create an Object with Property Name/Value Pairs from Arrays
Posted on June 9, 2015 in Algorithms, JavaScript by Matt Jennings

var keys = [“first_name”, “last_name”, “email”, “age”, “address”];
var values = [“elon”, “musk”, “0d041d2f2e10241b04012040072e05”, 35, “mars”];

function buildObject(nkeys, nvalues) {

Read more