Alphabet or how to make random string

var ranAlp = Math.floor(Math.random() * alphabet.length)
var randomString = ''
while (randomString.length < 7){
    randomString += ranAlp 
    console.log(randomString[ranAlp]) }
console output: RRRRRR

so the app takes any random of alphabet symbol, when I need to create random string with 6 different symbols. I dont understand why the app takes one random symbol instead of 6 different. Explain please :frowning:

ranAlp is defined only once, then you add it 6 times to randomString

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.