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
| // generate hint / score the guess | |
| // 0 wrong, 1 right letter wrong place, 2 right letter right place | |
| function generateHint(word: string, guess: string): string { | |
| // spread word into array | |
| const source = [...word] | |
| // map guess | |
| return [...guess].map((letter, 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
| cardDeck = { | |
| suits: ["♣️", "♦️", "♥️", "♠️"], | |
| court: ["J", "Q", "K", "A"], | |
| [Symbol.iterator]: function* () { | |
| for (let suit of this.suits) { | |
| for (let i = 2; i <= 10; i++) yield suit + i; | |
| for (let c of this.court) yield suit + c; | |
| } | |
| } | |
| } |
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
| <script> | |
| export default { | |
| data() { | |
| return { | |
| currentPage: 1, | |
| articles: [] | |
| } | |
| }, | |
| async fetch() { |
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 sumArrayReducer = (arr) => arr.reduce((a, b) => a + b, 0) | |
| sumArrayReducer([1, 2, 3, 4, 5]) // 15 |
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 reversedRangeArray = (num) => Array.from({ length: num }, (_, i) => num - i) | |
| reversedRangeArray(5) // [5, 4, 3, 2, 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 rangeArray = (endNum) => Array.from({ length: endNum }, (_, i) => i + 1) | |
| rangeArray(5) // [1, 2, 3, 4, 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
| sortBy(field) { | |
| this.applicantsInfo.sort((a, b) => { | |
| if (a[field] < b[field]) { | |
| return -1 | |
| } | |
| if (a[field] > b[field]) { | |
| return 1 | |
| } | |
| return 0 | |
| }) |
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
| filteredNames() { | |
| const key = 'name' | |
| const filter = new RegExp(this.filterText, 'i') | |
| return this.applicantsInfo.filter((el) => { | |
| if (el[key] !== undefined) { | |
| return el[key].toString().match(filter) | |
| } else return true | |
| }) | |
| }, |
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
| columnHeadingMap() { | |
| return this.columnKeys.reduce((acc, curr, index) => { | |
| acc[curr] = this.germanValues[index] | |
| return acc | |
| }, {}) | |
| }, | |
| // maps/reduces 2 arrays into an new object | |
| // vue computed |
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 shuffle(array) { | |
| for (let i = array.length - 1; i > 0; i--) { | |
| const j = Math.floor(Math.random() * (i + 1)) | |
| ;[array[i], array[j]] = [array[j], array[i]] | |
| } | |
| return array | |
| } | |
| // Snippet by Sarah Drasner | |
| // More shuffling ---> https://bost.ocks.org/mike/shuffle/ |
NewerOlder