我想使用javascript创建包含1000个单词的虚拟文本。我的想法是使用这样的数组使用javascript创建虚拟文本
var words =["The sky", "above", "the port","was", "the color of television", "tuned", "to", "a dead channel", ".", "All", "this happened", "more or less","." ,"I", "had", "the story", "bit by bit", "from various people", "and", "as generally", "happens", "in such cases", "each time", "it", "was", "a different story","." ,"It", "was", "a pleasure", "to", "burn"];
然后使用javascript输出1000个字随机。我将如何使用JavaScript?任何其他方式来做到这一点?
[从阵列获得的随机值]的可能的复制(http://stackoverflow.com/questions/4550505/getting-random - 值从 - 一个阵列)。 < - 只需做1000次,将每个结果推送到一个数组,然后在“”上加入它,或者简单地追加到每个迭代上的字符串 – Phil
(for var i = 1000; i--;)document.body.innerHTML + = words [Math.floor(Math.random()* words.length)];' – adeneo