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
// JOIN Parsity.io amigo | |
// a coding program where we teach you to build software, work with experts and get coached towards your first (software) job! | |
// Import express module | |
const express = require('express'); | |
const cors = require('cors'); | |
//whitelist all the domains | |
// Create an express application |
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 backtrackingProblem = (input) => { | |
const finalResult = [] | |
const recurse = (curSolution, arg) => { | |
// base case - does our solution work? | |
if(isBadSolution(curSolution)) return | |
// add our final solution |
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
import subroutes from '../routes'; | |
import { addTrailingSlashIfNone } from '../utils/helpers'; | |
/* | |
function to determine the redirect route based on the currentLocaion | |
*/ | |
const determineRedirect = (currentLocaion) => { | |
if (subroutes & seoData) { |
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
/* | |
a closure gives you access to an outer function's scope from an inner function. | |
*/ | |
const adder = (initialNum) => { | |
return(nextNum) => { | |
return initialNum + nextNum | |
} | |
} |
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 { flattenArr, dataFetcher, createList } = require('./myFunc'); | |
const axios = require('axios'); | |
jest.mock('axios', () => ({ | |
get: jest.fn(), | |
})); | |
describe.skip('flattenArr', () => { | |
it('return a non-nested arr', () => { | |
const input = [1, 2, 3, 4]; |
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 axios = require('axios'); | |
const flattenArr = (arr) => { | |
const retVal = []; | |
const helper = (val) => { | |
for (let i = 0; i < val.length; i++) { | |
if (Array.isArray(val[i])) { | |
helper(val[i]); | |
} else { |
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
import apiClient from './apiClient'; | |
import ShoppingCart from './ShoppingCart'; | |
const ShoppingCartContainer = ({apiClient}) => { | |
const [errorMessage, setErrorMessage] = useState(null) | |
const isLoggedIn = useSelector((state) => state.account.isLoggedIn); | |
const urlToUse = isLoggedIn ? 'https://api/customercheckout' : 'https://api/guestcheckout'; | |
const addToCartFunction = async (items) => { |
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 ShoppingCart = () => { | |
const [errorMessage, setErrorMessage] = useState(null) | |
const isLoggedIn = useSelector((state) => state.account.isLoggedIn); | |
const urlToUse = isLoggedIn ? 'https://api/customercheckout' : 'https://api/guestcheckout'; | |
const addToCartFunction = async (items) => { | |
const { data, errors } = await axios.post(urlToUse, {items}); | |
if(errors){ |
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 Cart = ({items, isLoggedIn, btnCallBack}) => { | |
if(!isLoggedIn){ | |
return <LoginPrompt/> | |
} | |
return( | |
<div> | |
<div> | |
{items.map(({price, name}) => { |
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 Cart = ({items}) => { | |
const dispatch = useDispatch() | |
const isLoggedIn = useSelector((state) => state.account.isLoggedIn) | |
const clearCart = () => { | |
dispatch(reduxActionToClearCart()) | |
} | |
if(!isLoggedIn){ |
NewerOlder