Skip to content

Instantly share code, notes, and snippets.

View rickMcGavin's full-sized avatar
🎧

Rick McGavin rickMcGavin

🎧
View GitHub Profile
// freecodecamp
// intermediate algorithm scripting
// smallest common multiples
// Find the smallest common multiple of the provided parameters that can be evenly divided by both, as well as by all sequential numbers in the range between these parameters.
// The range will be an array of two numbers that will not necessarily be in numerical order.
// e.g. for 1 and 3 - find the smallest common multiple of both 1 and 3 that is evenly divisible by all numbers between 1 and 3.
// project euler challenge 1
// sum all the natural numbers between 0 - 1000 that are divisible by 3 or 5
function sumMultiples(num) {
var sum = 0; // declare sum as a variable
for (var i = 0; i < num; i++) { // loop from 0 - num, iterating 1
if (i % 3 === 0 || i % 5 === 0) { // if i is divisible by 3 or 5
sum += i; // add i to the running sum
}
}
// freecodecamp
// intermediate algorithm scripting
// sum all primes
function sumPrimes(num) {
// create empty array to hold primes
var arr = [];
// create sum variable
var sum = 0;
// freecodecamp
// intermediate algorithm scripting
// sum all odd numbers in a fibonacci sequence
function sumFibs(num) {
var a = 0;
var b = 1;
var c = 0;
while (b <= num) {
// freecodecamp
// intermediate algorithm scripting
// this is spinal case
function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
// break the string in to an array
var arr = str.split('');
// freecodecamp
// intermediate algorithm scripting
// convert HTML entities
function convertHTML(str) {
// break string in to an array
var arr2 = str.split("");
// check if letter matches html element & reassign the value
arr2.forEach(function(char, index) {
if (char === "&") {
function uniteUnique(arr) {
// create empty array variable
var arr2 = [];
// loop through arguments
for (var i = 0; i < arguments.length; i++) {
// loop through arguments[i]
for (var j = 0; j < arguments[i].length; j++){
// check to see if values already exist in arr2
// freecodecamp
// intermediate algorithm scripting
// Boo Who
function booWho(bool) {
// What is the new fad diet for ghost developers? The Boolean.
if (bool === false || bool === true) {
return true;
} else {
return false;
// freecodecamp
// intermediate algorithm scripting
// missing letters
function fearNotLetter(str) {
// set a variable to initial unicode value
var unicodeCounter = str[0].charCodeAt(0);
// iterate through the string
for (var i = 0; i < str.length; i++) {
// FreeCodeCamp
// Intermediate Algorithm Scripting
// DNA Pairing
function pairElement(str) {
// break string into an array
var arr = str.split("");
var arr2 = [];
// loop through initial array