Pick a random letter from string in JavaScript

前端 未结 4 542
闹比i
闹比i 2021-01-03 10:58

This question is different from Take random letters out from a string because I am not trying to remove anything from the string.

I\'m trying to pick a rand

4条回答
  •  萌比男神i
    2021-01-03 11:12

    While those above are nice. I like shorter code.

    const randomLetter = ('abcdefghijklmnopqrstuvwxyz').split('')[(Math.floor(Math.random() * 26 ))];
    

提交回复
热议问题