Javascript examples for Array Operation:Array Index
Create paragraph from random array of words
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {//w w w. ja v a2 s .c o m var words = ['apple', 'beer', 'cake', 'potato', 'orange','test','joe'], div = document.getElementById('foo'); for(i = 0; i < 50; i++) { div.innerHTML += ' ' + words[Math.floor(Math.random() * words.length)]; } }); </script> </head> <body> <div id="foo"></div> </body> </html>