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 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 = ""; | |
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 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; |
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 Challenges | |
function diffArray(arr1, arr2) { | |
var newArr = []; | |
arr1.forEach(function(num) { | |
if (!arr2.includes(num)) { | |
newArr.push(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 | |
// 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]; |
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 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; | |
} |
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
// 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; |
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 |
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 | |
// 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
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 |
OlderNewer