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 _ from 'lodash'; | |
| function swatch(color) { | |
| console.log(`Color is ${color}`); | |
| return `Color is ${color}` | |
| } | |
| const memoizedSwatch = _.memoize(swatch); | |
| memoizedSwatch("blue"); | |
| memoizedSwatch("red"); |
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 expect = (actual, expected) => { | |
| if (actual !== expected) { | |
| console.log(`Expected ${actual} to equal ${expected}`); | |
| } | |
| }; | |
| var containsDuplicate = function (nums) { | |
| var map = new Map(); | |
| for (const elm of nums) { |
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 createHash = (item) => JSON.stringify(item); | |
| const memoize = (original) => { | |
| const cache = {}; | |
| return (...args) => { | |
| const hash = createHash(args); | |
| if (cache.hasOwnProperty(hash)) { | |
| return cache[hash]; | |
| } | |
| cache[hash] = original(...args); |
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 array = [ | |
| { | |
| name: 'salvador', | |
| age: 99, | |
| gender: 'male', | |
| children: [ | |
| { | |
| name: 'felix', | |
| age: 67, | |
| gender: 'male', |
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 toppings = [ | |
| { | |
| id: 1, | |
| subOptions: [ | |
| { id: 2, subOptions: [{ id: 3, checked: false }], checked: false }, | |
| ], | |
| checked: false, | |
| }, | |
| { id: 2, subOptions: [], checked: false }, | |
| { id: 3, subOptions: [{ id: 5, checked: false }], checked: false }, |
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
| // interface Topping { | |
| // // name: string; | |
| // id: number; | |
| // subOptions?: Topping[]; | |
| // checked?: boolean; | |
| // } | |
| const toppings = [ | |
| { | |
| id: 1, |
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 square = (n: number) => { | |
| let res = 0; | |
| for (let i = 0; i < n; i++) { | |
| for (let j = 0; j < n; j++) { | |
| i; | |
| j; | |
| res += 1; | |
| } | |
| } | |
| return res; |
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 animals = [ | |
| { | |
| id: 1, | |
| type: 'cat', | |
| pets: [ | |
| { id: 1, name: 'Toby', breed: 'Tabby', cute: true }, | |
| { id: 2, name: 'Golden Girl', breed: 'Russian Blue', cute: false }, | |
| ], | |
| }, | |
| { |
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 myObj = { | |
| id: 1, | |
| anyProp: [{ | |
| id: 2, | |
| thing: { a: 1, id: 10 }, | |
| children: [{ id: 3 }] | |
| }, { | |
| id: 4, | |
| children: [{ | |
| id: 5, |
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 data = [ | |
| { | |
| title: 'some title', | |
| channel_id: '123we', | |
| options: [ | |
| { | |
| channel_id: 'abc', | |
| image: 'http://asdasd.com/all-inclusive-block-img.jpg', | |
| title: 'All-Inclusive', | |
| options: [ |
NewerOlder