Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

make id of certain length js

function makeID (length) { //Generates an id of <length> that never starts with 0
  	length --; 
	const id = parseInt(Math.floor(Math.random() * (9 - 1) + 1) + "" + Math.floor(Math.random() * 10 ** length)); 
  	return id;
}
 
PREVIOUS NEXT
Tagged: #id #length #js
ADD COMMENT
Topic
Name
8+7 =