I want to repeat the for loop which get us new values every time.
Whenever I will run the for loop I should get the values different.
Please solve my problem
let hex = 'ABCDEF0123456789';
let res = '';
for (let i = 1; i <= 6; i++) {
res += hex.charAt(Math.floor(Math.random() * hex.length));
// console.log(i);
}
I want to get new values every time when I call or run the for loop.
For Example – If I print the value of res multiple times. Every time
I want the value different
2
Answers
Did you mean that you want to put your code in a function an call the function?