Skip to content

Instantly share code, notes, and snippets.

@stoutlabs
Last active July 21, 2022 14:44
Show Gist options
  • Save stoutlabs/89f0aa3781e54cc5f060c51d324a5e43 to your computer and use it in GitHub Desktop.
Save stoutlabs/89f0aa3781e54cc5f060c51d324a5e43 to your computer and use it in GitHub Desktop.
// 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