Blog

Archive for the Algorithms Category


Remove Duplicates from Array in JavaScript
Posted on July 24, 2019 in Algorithms, JavaScript by Matt Jennings

function removeDuplicates(arr) {
var arrNoDupes = [];

// Iterate through array passed in by parameter

Read more


Prime Number Checker in JavaScript
Posted on June 19, 2019 in Algorithms, JavaScript by Matt Jennings

function checkPrime(num) {
var primeCheckerArr = [];

for(var i = 2; i <= num; i++) {

Read more


Find Unique Characters in a String
Posted on June 19, 2019 in Algorithms, JavaScript by Matt Jennings

var string = ‘what a wonderful day it has been!’;

function firstNonRepeatedChar(str) {
for(var i = 0; str.length; i++) {

Read more


Code to Get Unique Elements of an Array using ES6 Syntax
Posted on February 6, 2019 in Algorithms, JavaScript by Matt Jennings

const arr1 = [2, 2, 4, 2, 6, 4, 7, 8]

const counts = {}

let i

for (i = 0; i < …

Read more


Determine if a String Contains a Palindrome in JavaScript
Posted on December 7, 2017 in Algorithms, JavaScript, Regular Expressions by Matt Jennings

Determine if a string contains a palindrome in JavaScript.
Strip out any non Latin alphabetic characters if needed.

var str = ‘!Noel …

Read more