This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// freecodecamp | |
// intermediate algorithm scripting | |
// sum all primes | |
function sumPrimes(num) { | |
// create empty array to hold primes | |
var arr = []; | |
// create sum variable | |
var sum = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 === "&") { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FreeCodeCamp | |
// Intermediate Algorithm Scripting | |
// DNA Pairing | |
function pairElement(str) { | |
// break string into an array | |
var arr = str.split(""); | |
var arr2 = []; | |
// loop through initial array |