Blog

Archive for the JavaScript Category


Multiple Ways to Use For Loops with Arrays and Object Literals in JavaScript
Posted on July 6, 2015 in JavaScript by Matt Jennings

var myArr = [1, 4, -9, -5, 5, 2];

for(index in myArr) {
console.log(myArr[index]);
}

/*
Displays:
1
4
-9
-5
5
2
*/

// The object key names must be …

Read more


JavaScript Function that Takes in a String and Outputs an Object Literal that Counts Characters
Posted on June 24, 2015 in Algorithms, JavaScript by Matt Jennings

function countChar(string) {

// Create an empty object
var countCharObj = {};

// …

Read more


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