Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript get random character from string

const array = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ];
const string = "abcdefghijklmnopqrstuvwxyz";

// random item from Array
console.log(array[Math.floor(Math.random() * array.length)]);

// random Char from String
console.log(string[Math.floor(Math.random() * string.length)]);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #random #character #string
ADD COMMENT
Topic
Name
2+1 =