我正在用javascript创建刽子手,我(我认为)成功地从函数中的数组生成了一个随机词,以检查它是否有效我试图将生成的词打印到控制台,但它似乎不是在这里工作是我的函数代码
var word = function() //Random word is genereated from an array for the user to guess
{
GameWordArray = new Array(7);
GameWordArray[0] = "monitor";
GameWordArray[1] = "program";
GameWordArray[2] = "application";
GameWordArray[3] = "keyboard";
GameWordArray[4] = "javascript";
GameWordArray[5] = "gaming";
GameWordArray[6] = "network";
randno = Math.floor(Math.random() * GameWordArray.length);
document.write(GameWordArray[randno]);
console.log(word);
}
提前致谢 :)