Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Generate Random String

// Create a function for reusable perpose
const generateRandomString = (myLength) => {
  const chars =
    "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890";
  const randomArray = Array.from(
    { length: myLength },
    (v, k) => chars[Math.floor(Math.random() * chars.length)]
  );

  const randomString = randomArray.join("");
  return randomString;
};

// Try it
console.log(generateRandomString(10));
console.log(generateRandomString(30));
Source by www.kindacode.com #
 
PREVIOUS NEXT
Tagged: #Generate #Random #String
ADD COMMENT
Topic
Name
4+5 =