Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript get random line from text file

$.get('txt/messages.txt', function(txt) {
var lines = txt.responseText.split("
");
var randLineNum = Math.floor(Math.random() * lines.length);
return lines[randLineNum]; // random line from the text file
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #random #line #text #file
ADD COMMENT
Topic
Name
6+5 =