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
// Docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch | |
// https://guide.freecodecamp.org/certifications/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/dna-pairing | |
function pairElement(str) { | |
var paired = []; | |
var search = function(char) { | |
switch (char) { | |
case 'A': | |
console.log("a found"); |
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 fearNotLetter(str) { | |
var c = 0; | |
var i = 0; | |
if (str) { | |
i = str.charCodeAt(0); | |
while (c < str.length && i < 122) { | |
if (String.fromCharCode(i) !== str.charAt(c)) { | |
return String.fromCharCode(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
function uniteUnique(arr) { | |
var newArray = []; | |
for (let array of arguments) { | |
newArray.push(array); | |
} | |
var flatArray = newArray.flat() | |
var unique = [...new Set(flatArray)]; |
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 convertHTML(str) { | |
var htmlStr = ""; | |
var search = function(char) { | |
switch (char) { | |
case '&': | |
console.log("& found"); | |
str = str.replace("&", "&"); | |
break; | |
case '<': |
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 sumFibs(num) { | |
var prevNumber = 0; | |
var currNumber = 1; | |
var result = 0; | |
while (currNumber <= num) { | |
if (currNumber % 2 !== 0) { | |
result += currNumber; | |
} |
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 sumPrimes(num) { | |
function isPrime(num) { | |
if(num < 2) return false; | |
for (var i = 2; i < num; i++) { | |
if(num%i==0) | |
return false; | |
} | |
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
// Stolen from fCC solutions - could not figure it out | |
function smallestCommons(arr) { | |
// Sort array from greater to lowest | |
// This line of code was from Adam Doyle (http://github.com/Adoyle2014) | |
arr.sort(function(a, b) { | |
return b - a; | |
}); | |
// Create new array and add all values from greater to smaller from the |
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 dropElements(arr, func) { | |
// Drop them elements. | |
for (var i = 0; i <= arr.length; i++) { | |
// Check console for current value | |
console.log("function is " + func(arr[0])); | |
console.log("value is " + arr[0]) | |
// remove value from arr if function returns false | |
if(func(arr[0]) === 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 truthCheck(collection, pre) { | |
// Is everyone being true? | |
var counter = 0; | |
for (let c in collection) { | |
if (collection[c].hasOwnProperty(pre) && Boolean(collection[c][pre])) { | |
counter++; | |
} | |
} |
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
const SecretRoute = ({ component: Component, ...rest }) => ( | |
<Route {...rest} render={(props) => ( | |
AuthService.isAuthenticated === true | |
? <Component {...props} /> | |
: <Redirect to='/login' /> | |
)} /> | |
); |
OlderNewer