Last active
November 28, 2023 12:17
-
-
Save pasikonik/777246c46a348782bb690b860f80d973 to your computer and use it in GitHub Desktop.
JavaScript snippets
This file contains 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
// 1. Get a random integer between two integers | |
const random = (min, max) => Math.floor(Math.random() * (max - min + 1) + min) | |
// 2. Check if an object is an empty object | |
const isEmpty = obj => Reflect.ownKeys(obj).length === 0 && obj.constructor === Object | |
// Shuffle array | |
const shuffleArray = (arr) => arr.sort(() => Math.random() - 0.5) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment