Skip to content

Instantly share code, notes, and snippets.

View basekays's full-sized avatar

Hyejin Kay Albito basekays

View GitHub Profile
//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
//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++) {
//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--) {
//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();
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;
}
componentWillMount() {
let id = null;
if (this.props.placeId) {
id = this.props.placeId;
} else {
id = this.props.id;
}
this.props.actions.getPlaceDetail(id);
}
export getPlacesIndex from './getPlacesIndex';
export getWishlistIndex from './getWishlistIndex';
export postWishlistPlaces from './postWishlistPlaces';
export deleteWishlistPlaces from './deleteWishlistPlaces';
import express from 'express';
import bodyParser from 'body-parser';
import Sequelize from 'sequelize';
import morgan from 'morgan';
import {
getPlacesIndex,
getWishlistIndex,
postWishlistPlaces,
deleteWishlistPlaces,
export default function (state = INITIAL_STATE, action = {}) {
const {
type,
wishlistItem,
} = action;
switch (type) {
case ADD_TO_WISHLIST_SUCCESS:
return {
...state,
index: [...state.index, {
export default (req, res) => {
const {
WishlistPlaces,
} = req.app.models;
const placeId = req.body.placeId;
console.log('******************************************');
console.log(placeId);
WishlistPlaces.findOrCreate({