function myFunction() {
var x = document.getElementById("demo");
var alhpabet = ["ABCDEFGHIJKLMNOPQRSTUVWXYZ"];
x.innerHTML = Math.floor((Math.random() * alhpabet.lengthS));
}
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
怎样才能用JavaScript一个字母?
你还需要这封信被插入到'demo'元素? – damienc
'alhpabet.lengthS'>'alhpabet.length' – Roberrrt