Blog

Archive for the Algorithms Category


In JavaScript Sort Numbers using the sort() Function
Posted on November 28, 2017 in Algorithms, JavaScript by Matt Jennings

Sort Numbers In Ascending Order

var numbers = [2, 1, 111, 222, 33, -2];

// Output is [-19, -2, 1, 33, 111,
Read more…


In JavaScript Show Longest Word in a String
Posted on November 28, 2017 in Algorithms, JavaScript, Regular Expressions by Matt Jennings

function longestWord(sen) {
// ‘sen’ is a string and ‘match’
// matches all the items in the
Read more…


Determine If a Positive Integer is a Prime Number Using JavaScript
Posted on November 27, 2017 in Algorithms, JavaScript by Matt Jennings

function getPrimeNumber(num) {

var arr = [];

for(var i = 1; i < num +
Read more…


In JavaScript Reverse a String without using reverse()
Posted on November 12, 2017 in Algorithms, JavaScript by Matt Jennings

var str = ‘blah’;

function reverseStr(str1) {
var arr1 = str1.split(”);
var arr2 = [];

Read more…


Basic Ruby Algorithms
Posted on August 6, 2015 in Algorithms, Ruby by Matt Jennings

Print Numbers 1 through 255 Using a For Loop

for i in 1..255
puts “#{i}”
end

Print Numbers 1 through 255 Using
Read more…

To Top ↑