Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

random key generator

const random = (length = 8) => {
    // Declare all characters
    let chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

    // Pick characers randomly
    let str = '';
    for (let i = 0; i < length; i++) {
        str += chars.charAt(Math.floor(Math.random() * chars.length));
    }

    return str;

};

console.log(random()); // JgKGQEUx
console.log(random(12)); // ttwbeshkYzaX
console.log(random(20)); // zZN7uH9pPjhJf30QNus5
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript replace tag 
Javascript :: vue style background color 
Javascript :: enzyme testing 
Javascript :: JavaScript setTimeout js function timer command 
Javascript :: javascript function 
Javascript :: jquery validate add rules dynamically 
Javascript :: object comparison in javascript 
Javascript :: how to retrieve the list value of json file in python 
Javascript :: see if array contains array javascript 
Javascript :: console.log(...) is not a function 
Javascript :: iterate over array javascript 
Javascript :: vue directive 
Javascript :: mongoose await save 
Javascript :: javaScript new Set() Method 
Javascript :: javascript parse date in current timezone 
Javascript :: angular multiselect dropdown 
Javascript :: javscript rename property name 
Javascript :: What is array.push in javascript 
Javascript :: scroll btn 
Javascript :: convert json / array to excel in javascript 
Javascript :: convert html to png javascript 
Javascript :: prepend to js array 
Javascript :: how to return json data from mvc controller to view 
Javascript :: how to separate string elements in javascript 
Javascript :: image to base64 js 
Javascript :: react native build 
Javascript :: angularjs show form validation errors 
Javascript :: convert array to object with custom keys 
Javascript :: Searchkick::ImportError: {"type"="cluster_block_exception" 
Javascript :: how to highlight active screen react native 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =