Skip to content

Instantly share code, notes, and snippets.

View rickMcGavin's full-sized avatar
🎧

Rick McGavin rickMcGavin

🎧
View GitHub Profile
// FreeCodeCamp intermediate algorithm challenge
// convert number to roman numeral
function convertToRoman(num) {
var decNum = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ];
var romanNum = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I' ];
var final = "";
// FreeCodeCamp //
// Intermediate Algorithm Challenges
// Pass in an array of two numbers
// Sum the two numbers in the array
// plus all numbers in between
function sumAll(arr) {
lowest = Math.min(arr[0], arr[1]);
highest = Math.max(arr[0], arr[1]);
var total = 0;
// FreeCodeCamp
// Intermediate Algorithm Challenges
function diffArray(arr1, arr2) {
var newArr = [];
arr1.forEach(function(num) {
if (!arr2.includes(num)) {
newArr.push(num);
}
});
// FreeCodeCamp
// Intermediate Algorithm Scripting
// Wherefore Art Though
function whatIsInAName(collection, source) {
// What's in a name?
var keys = Object.keys(source);
return collection.filter(function(obj) {
return keys.every(function(key) {
return obj.hasOwnProperty(key) && obj[key] === source[key];
// FreeCodeCamp
// Intermediate Algrothim Scripting
// search and replace
// test if a letter is uppercase
function isUpper(letter) {
var charCode = letter.charCodeAt(0);
if (charCode > 64 && charCode < 91) {
return true;
}
// create string of vowels to check arguments against
var vowels = "aeiou";
var conCluster = "";
var vowCluster = "";
function translatePigLatin(str) {
// assign first vowel index to the length of the string
var firstVowelIndex = str.length;
// FreeCodeCamp
// Intermediate Algorithm Scripting
// DNA Pairing
function pairElement(str) {
// break string into an array
var arr = str.split("");
var arr2 = [];
// loop through initial array
// 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
// 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;
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