Blog

Archive for the JavaScript Category


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


Examples of Choosing Random Numbers in JavaScript
Posted on June 8, 2015 in JavaScript by Matt Jennings

// Returns a random number between 0 (inclusive) and 1 (exclusive)
Math.random();

// Returns the largest integer less than or equal to …

Read more


In JavaScript Write an Array Containing 10 Arrays
Posted on June 8, 2015 in Algorithms, JavaScript by Matt Jennings

In JavaScript create an array containing 10 arrays. Those 10 separate arrays should each contain a randomly selected string value …

Read more


In JavaScript Write a Function to Split a String USING split();
Posted on June 5, 2015 in Algorithms, JavaScript by Matt Jennings

function mySplit(string, delimiter) {
var strArray = string.split(delimiter);
return strArray;
}

console.log(mySplit(“hello world and stuff”, ” “));