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 ADD_NOTE = 'ADD_NOTE'; | |
const notesReducer = (state = 'Initial State', action) => { | |
switch(action.type) { | |
// change code below this line | |
case ADD_NOTE: | |
return action.text | |
// change code above this line | |
default: | |
return state; |
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 ADD = 'ADD'; | |
const reducer = (state = 0, action) => { | |
switch(action.type) { | |
case ADD: | |
return state + 1; | |
default: | |
return state; | |
} | |
}; |
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 checkCashRegister(price, cash, cid) { | |
var change = 0; | |
var difference = cash - price; | |
console.log(difference) | |
// Create object with status & change key | |
var cashreg = { | |
status: "", | |
change: [] | |
} |
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 addTogether() { | |
// Function to check if a number is actually a number | |
// and return undefined otherwise. | |
var checkNum = function(num) { | |
if (typeof num !== 'number') { | |
return undefined; | |
} else | |
return 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
const SecretRoute = ({ component: Component, ...rest }) => ( | |
<Route {...rest} render={(props) => ( | |
AuthService.isAuthenticated === true | |
? <Component {...props} /> | |
: <Redirect to='/login' /> | |
)} /> | |
); |
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
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
// 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 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
function sumFibs(num) { | |
var prevNumber = 0; | |
var currNumber = 1; | |
var result = 0; | |
while (currNumber <= num) { | |
if (currNumber % 2 !== 0) { | |
result += currNumber; | |
} |