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 axios from 'axios'; | |
import {AUTH_USER, UNAUTH_USER, AUTH_ERROR} from './types'; | |
import authError from './error'; | |
const ROOT_URL = 'http://localhost:3000/'; // url to api | |
export default function signinUser(email,password) { |
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 { AUTH_USER, UNAUTH_USER, AUTH_ERROR } from '../actions/types.js'; // types | |
export default function (state = {}, action) { | |
switch (action.type) { //set up switch | |
case AUTH_USER: | |
return { ...state, error: "", authenticated: true }; // return previous state as spread operator plus updated state | |
case UNAUTH_USER: | |
return { ...state, authenticated: false }; | |
case AUTH_ERROR: | |
return { ...state, error: action.payload }; |
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
/* | |
We'll pass you an array of two numbers. Return the sum of those two numbers and all numbers between them. | |
The lowest number will not always come first. | |
*/ | |
function sumAll(arr) { | |
var newArray = []; | |
var result; |
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
/* | |
Compare two arrays and return a new array with any items only found in one of the two given arrays, but not both. | |
In other words, return the symmetric difference of the two arrays. | |
*/ | |
function diffArray(arr1, arr2) { | |
var newArr = []; | |
function check(first, second) { |
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
/* | |
Convert the given number into a roman numeral. | |
All roman numerals answers should be provided in upper-case. | |
*/ | |
function convertToRoman(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
/* | |
Make a function that looks through an array of objects (first argument) and returns an array of all objects that have | |
matching property and value pairs (second argument). Each property and value pair of the source object has to be present | |
in the object from the collection if it is to be included in the returned array. | |
For example, if the first argument is [{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, | |
{ first: "Tybalt", last: "Capulet" }], and the second argument is { last: "Capulet" }, | |
then you must return the third object from the array (the first argument), because it contains the property and | |
its value, that was passed on as the second argument. |
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
/* | |
Perform a search and replace on the sentence using the arguments provided and return the new sentence. | |
First argument is the sentence to perform the search and replace on. | |
Second argument is the word that you will be replacing (before). | |
Third argument is what you will be replacing the second argument with (after). | |
NOTE: Preserve the case of the original word when you are replacing it. For example if you mean to replace the word |
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
/* | |
Translate the provided string to pig latin. | |
Pig Latin takes the first consonant (or consonant cluster) of an English word, moves it to the end of the word and suffixes an "ay". | |
If a word begins with a vowel you just add "way" to the end. | |
Input strings are guaranteed to be English words in all lowercase. | |
*/ |
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
/* | |
The DNA strand is missing the pairing element. Take each character, get its pair, and return the results as a 2d array. | |
Base pairs are a pair of AT and CG. Match the missing element to the provided character. | |
Return the provided character as the first element in each array. | |
For example, for the input GCG, return [["G", "C"], ["C","G"],["G", "C"]] | |
The character and its pair are paired up in an array, and all the arrays are grouped into one encapsulating 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
/* | |
Find the missing letter in the passed letter range and return it. | |
If all letters are present in the range, return undefined. | |
*/ | |
function fearNotLetter(str) { | |
str = str.split(''); | |
var alphabet = 'abcdefghijklmnopqrstuvwxyz'; | |
alph = alphabet.split(''); |