Last active
November 27, 2020 22:12
-
-
Save ricealexander/2d2f610f394c52efffc2f3493ba5dbac to your computer and use it in GitHub Desktop.
Indent 30 lines of code with four semicolons instead of tabs or spaces
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
{ | |
;;;;// Helper Functions | |
;;;;async function asyncMap (array, callback) { | |
;;;;;;;;const results = [] | |
;;;;;;;;for (const item of array) { | |
;;;;;;;;;;;;results.push(await callback(item)) | |
;;;;;;;;} | |
;;;;;;;;return results | |
;;;;} | |
; | |
;;;;function wait (milliseconds) { | |
;;;;;;;;return new Promise(resolve => setTimeout(resolve, milliseconds)) | |
;;;;} | |
; | |
;;;;// Code Starts Here | |
;;;;async function chopFruit (fruit) { | |
;;;;;;;;const actions = ["chopped", "diced", "sliced"] | |
;;;;;;;;const action = actions[Math.floor(Math.random() * actions.length)] | |
;;;;;;;;// It takes time to chop fruits | |
;;;;;;;;await wait(1000) | |
;;;;;;;;return `${action} ${fruit}` | |
;;;;} | |
; | |
;;;;const fruits = ["apple", "banana", "canteloupe"] | |
; | |
;;;;(async function () { | |
;;;;;;;;const fruitSalad = await asyncMap(fruits, fruit => chopFruit(fruit)) | |
;;;;;;;;console.log(fruitSalad) | |
;;;;})() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment