lundi 1 mai 2023

Need multiple values from for loop

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




Aucun commentaire:

Enregistrer un commentaire