0

I'm trying to randomly generate a consonant but I'm running into trouble.

I created an array with all the consonants and am able to generate a random number. What I'm trying to do now is associate that random number with its matching index number from the array to print out the character.

See my code below I hope that makes sense! Thanks!


function genCon(){

var con = ["b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","y","z"];

var randomCon = Math.floor((Math.random()*con.length)+1);

console.log(randomCon);

} 
Nick Parsons
  • 45,728
  • 6
  • 46
  • 64
cpog90
  • 97
  • 6

0 Answers0