Last active
July 26, 2020 13:54
-
-
Save bengrunfeld/9f6c2fa03556f5ae4cf749f89291d5be to your computer and use it in GitHub Desktop.
Toolbox of Useful Code
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
// Find the min of an array | |
const a = [3, 8, 2, 99, 1, 42, 23] | |
Math.min.apply(Math, a) | |
// How to turn an array into an object | |
const a = [3, 8, 2, 99, 1, 42, 23] | |
const b = a.reduce((a, b, i) => { | |
const obj = {} | |
obj[i] = b | |
return obj | |
}, {}) | |
// Create a dynamic array and fill it with random numbers | |
[...Array(20).keys()].map(() => Math.floor(Math.random() * 100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment