am trying to animate the random code that is for example 20345-6423-AGFDS and what am trying to do is when generating the code to animate it digit by digit. The first digit shuffles and picks 2, then the second digit and picks 0 and on and on and on till the last.
<div id="code"></div>
<br>
<button onclick="generate()"> Generate Code </button>
JS
function generate() {
document.getElementById("code").innerHTML = RanCode;
}
function randomString(length, chars) {
var result = '';
for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))];
return result;
}
function codeFunc(){
return (
randomString(5, '0123456789')
+ "-"
+ randomString(5, '0123456789')
+ "-"
+ randomString(5, 'ASDFGHJKL')
);
}
var RanCode = codeFunc();
Example how i want them to shuffle one by one like the number inside the dice. https://javascript-tutor.net/jSample/jsp_anidice.html