This file contains hidden or 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
| //input = array of string | |
| //output = array of string | |
| // test case | |
| // [[1,1,0],[1,0,1],[0,0,0]] | |
| // [[1,0,0],[0,1,0],[1,1,1]] | |
| function flipAndInvertImage(array) { | |
| var result = []; | |
| //horizontal flip |
This file contains hidden or 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
| //input = number | |
| //output = array of string | |
| //test case | |
| //5 | |
| // -> ['1', '2', 'Fizz', '4', 'Buzz']; | |
| function fizzBuzz(number) { | |
| var result = []; | |
| for (var i = 1; i <= number; i++) { |
This file contains hidden or 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
| //input = string | |
| //output = string (can be modified string or new string) | |
| //test case | |
| //'hello' | |
| // -> 'olleh' | |
| function reverseString1(string) { | |
| var resultString = ''; | |
| for (var i = string.length-1; i >= 0; i--) { |
This file contains hidden or 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
| //input: array (can be mulitdimensional array) | |
| //output: array (single array, no depth) | |
| //test | |
| //[1, 2, 3, [4, 5, [6]], 7]; | |
| // -> [1, 2, 3, 4, 5, 6, 7]; | |
| function arrayFlattener1(array, flattened = []) { | |
| while (array.length) { | |
| var value = array.shift(); |
This file contains hidden or 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 flattenArray = function (array, flattened = []) { | |
| for (let i = 0; i < array.length; i++) { | |
| if (Array.isArray(array[i])) { | |
| flattenArray(array[i], flattened); | |
| } else { | |
| flattened.push(array[i]); | |
| } | |
| } | |
| return flattened; | |
| } |
This file contains hidden or 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
| componentWillMount() { | |
| let id = null; | |
| if (this.props.placeId) { | |
| id = this.props.placeId; | |
| } else { | |
| id = this.props.id; | |
| } | |
| this.props.actions.getPlaceDetail(id); | |
| } |
This file contains hidden or 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
| export getPlacesIndex from './getPlacesIndex'; | |
| export getWishlistIndex from './getWishlistIndex'; | |
| export postWishlistPlaces from './postWishlistPlaces'; | |
| export deleteWishlistPlaces from './deleteWishlistPlaces'; |
This file contains hidden or 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 express from 'express'; | |
| import bodyParser from 'body-parser'; | |
| import Sequelize from 'sequelize'; | |
| import morgan from 'morgan'; | |
| import { | |
| getPlacesIndex, | |
| getWishlistIndex, | |
| postWishlistPlaces, | |
| deleteWishlistPlaces, |
This file contains hidden or 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
| export default function (state = INITIAL_STATE, action = {}) { | |
| const { | |
| type, | |
| wishlistItem, | |
| } = action; | |
| switch (type) { | |
| case ADD_TO_WISHLIST_SUCCESS: | |
| return { | |
| ...state, | |
| index: [...state.index, { |
This file contains hidden or 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
| export default (req, res) => { | |
| const { | |
| WishlistPlaces, | |
| } = req.app.models; | |
| const placeId = req.body.placeId; | |
| console.log('******************************************'); | |
| console.log(placeId); | |
| WishlistPlaces.findOrCreate({ |