Last active
July 21, 2022 14:44
-
-
Save stoutlabs/89f0aa3781e54cc5f060c51d324a5e43 to your computer and use it in GitHub Desktop.
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
// strip tags from HTML string | |
let strippedString = originalString.replace(/(<([^>]+)>)/gi, ""); | |
// remove any duplicates from an array of primitives. | |
const unique = [...new Set(arr)]; | |
// shuffle Array | |
const shuffleArray = (arr) => arr.sort(() => Math.random() - 0.5); | |
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
console.log(shuffleArray(arr)); | |
// check if an array is empty | |
let arr = [1,2,3,4]; | |
const arrIsEmpty = !(Array.isArray(arr) && arr.length > 0); | |
// make range | |
function range(start, end) { | |
return Array.from({ length: end - start + 1 }, (_, i) => i) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment