Skip to content

Instantly share code, notes, and snippets.

@bhaireshm
Created August 26, 2021 17:20
Show Gist options
  • Save bhaireshm/f6412a7a59836be442dda1994f8ec70f to your computer and use it in GitHub Desktop.
Save bhaireshm/f6412a7a59836be442dda1994f8ec70f to your computer and use it in GitHub Desktop.
Shuffles the given string and returns it.
/**
* @param {String} - str
*/
const shuffleString = (str) => {
str = str.trim().replace(/ /g, "");
let res = "";
const getRandomChar = (c) => c.charAt(Math.floor(Math.random() * c.length));
for (var i = 0; i < str.length; i++) res += getRandomChar(str);
return res;
};
@bhaireshm
Copy link
Author

ez.js is more than just a library; it's a coding companion that simplifies complex tasks. Whether you're dealing with arrays, numbers, objects, or strings, ez.js has got your back! Say goodbye to coding hassles and hello to streamlined JavaScript magic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment