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
| function high(x){ | |
| const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('') | |
| const scores = alphabet.map((_, index) => index + 1) | |
| const words = x.split(' ') | |
| const scoresMap = scores.reduce((a, word, index) => a = Object.assign(a, {[alphabet[index]]: word}) , {}) | |
| const rankList = words.reduce((accum, curr) => { | |
| const word = curr.split('').reduce((a, c, i) => a + scoresMap[c], 0) | |
| return [...accum, word] |
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 Todo { | |
| title: string | |
| description: string | |
| completed: boolean | |
| } | |
| type MyPick<T, K extends keyof T> = { | |
| [Key in K]: T[Key] | |
| } |
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
| function arrayDiff(a, b) { | |
| return a.filter((item)=>!b.includes(item)) | |
| } |
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
| function duplicateEncode(word) { | |
| const encodeTree = {} | |
| const characters = word.toLowerCase().split('') | |
| const stringArray = [] | |
| for (let i = 0; i <= characters.length - 1; i++) { | |
| const letter = characters[i] | |
| if (encodeTree[letter] === undefined) { | |
| encodeTree[letter] = 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 sizes = [640, 800, 1200, 1440]; | |
| [ | |
| sizes.small, | |
| sizes.big, | |
| sizes.bigger, | |
| sizes.large, | |
| ] = sizes; |
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
| function filterWithOptions<T extends {[key: string]: Object}, O extends {[key: string]: string}>(array: Array<T>, filterOptions: O): Array<T>{ | |
| const filterOptionsKeys: string[] = Object.keys(filterOptions) | |
| return array | |
| .filter((item: T) => | |
| filterOptionsKeys | |
| .every((key: string) => filterOptions[key] === item[key])) | |
| } |
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
| // @gabrielmodog - 16:00 - 25-07-2021 | |
| const canvas = document.querySelector("canvas#app") | |
| const context = canvas.getContext("2d") | |
| const POINT_SIZE = 4 | |
| const POINT_CENTER_SIZER = POINT_SIZE * 2 | |
| const SCALE_RATE = 0.5 | |
| const rect = { |
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
| function faro(deck){ | |
| const half = deck.slice(0, deck.length / 2) | |
| return deck | |
| .slice(0, half) | |
| .flatMap((card, index) => [card, deck[index + half]]) | |
| } |
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
| function removeSelectedOptions(array, selected){ | |
| return array.filter((item) => !selected.includes(item)) | |
| } |
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
| function every(array, test){ | |
| let bool = false | |
| array.forEach(item => test(item) ? bool = true : bool = false) | |
| return bool | |
| } |